Open lindig opened 3 years ago
Switching to https://github.com/dinosaure/multipart_form could be an option. Other people reported issues around handling of \r\n
in the library that is currently used multipart-form-data library for form decoding.
I've verified this with uploading a PNG file using the simple (unstyled) upload example. The uploaded file has two extra bytes at the end, which is also evident from the file size. Can anybody confirm or reject this bug?
I have the same issue.
An unsatisfactory fix is to remove the last two characters.
For instance, in the opium example, change the close
function to this:
let close filename file prev =
let* () = prev in
let* () = Lwt_unix.close file in
let new_size = (Unix.stat filename).st_size - 2 in
Lwt.return @@ Unix.truncate filename new_size
A file uploaded with the server in
/example/file_upload
is not identical to the original file as can be verified with a checksum. I believe a newline is added at the end of the file.To reproduce the bug, upload a file with the demo application (either the simple or more styled one) and compare the uploaded file against the original. If this bug is indeed universal, this would render uploading images and other binary formats impossible.