Open spasius opened 5 years ago
I've encountered the same issue. Posting more information, in case it's needed.
Server returns 400 with error:
{"description":"failed to parse a requested field","cause":{"description":"expected a file but got a field, or vice versa","cause":null}}
if you upload any text file. But if you rename the file to something else, then it can be uploaded successfully.
Steps to reproduce:
Start example:
cargo run --example simple-form
Create text file:
echo "Hello, world" > test.txt
Open http://localhost:8000/ in browser and try to upload "text.txt". It will fail with 400.
Rename this file:
mv test.txt test.txt1
Try to upload "text.txt1". It will succeed.
But I'm not experienced enough to to say whether it's a problem with example code or with rouille itself.
I can verify this bug still exists on rouille v3.4.0 and it also applies to .HTML files. It appears to be a conflict between the BufferedFile struct type and plain text uploads.
Update: It works if you use a String instead of BufferedFile, but the sacrifice is compatibility for .png and other non-text file types.
Error then trying to upload html file (source from examples): {"description":"failed to parse a requested field","cause":{"description":"expected a file but got a field, or vice versa","cause":null}}