I have a file that is roughly 51Mb (as seen in Finder). "GetInfo" shows Size: 51,534,849 bytes (52.3 MB on disk)
When I upload this file to the server the byteLength of the uploaded Buffer is a lot smaller. Does it depend on the file type or any other properties? How do I get the correct uploaded file size
import { UploadedFile } from "express-fileupload";
private getFileSize(fileUpload: UploadedFile) {
const fileData = fileUpload.data;
console.log(fileData.byteLength, fileData.length, Buffer.byteLength(fileData))
return fileData.???;
}
In the above fileData.byteLength, fileData.length, Buffer.byteLength(fileData) all give the same result of 18118252, which divided by 1024 is roughly 17Mb
I am using Postman, if it matters

By looking at the documentation of express-fileupload there is a field on the fileUpload object that's named size which should return you the size of the file in bytes.
Regarding the misleading buffer size, not sure why that is. Typically when receiving files, they come in chunks that have to be asynchronously collected before concating the chunks into the file. I assume that the package express-fileupload does that for you. Try saving the file to the disk and have a look at the file size and see if it's the same as before the upload.