Closed
Description
The bug: By uploading a shorter file after uploading a bigger file, the original file bytes are still there.
Expected behaviour: The new file should be truncated first.
To reproduce
Caddyfile
{
order upload before file_server
}
http://localhost {
root * ./uploads
upload method POST {
dest_dir ./uploads
file_field_name f
max_filesize 512M
}
}
echo '{"yo": "this is my original file, that is pretty long"}' > my_file.json
curl -F f=@my_file.json http://localhost
echo '{"yo": "this is short"}' > my_file.json
curl -F f=@my_file.json http://localhost
cat ./uploads/my_file.json
{"yo": "this is short"}inal file, that is pretty long"}
Obviously, I expected the output {"yo": "this is short"}
instead of a broken JSON file.
tempFile, tmpf_err := os.OpenFile(u.DestDir+"/"+handler.Filename, os.O_RDWR|os.O_CREATE, 0755)
Adding os.O_TRUNC
to the options may fix the issue. I've not tested it.
Metadata
Metadata
Assignees
Labels
No labels