Closed davidgatti closed 5 years ago
@davidgatti show an example
I'd also like to know about this. I'm trying to save an .webm file and while the resulting file size is correct, the video does not open. Maybe it's the file writing in itself that's not right? Here's my code:
module.exports.handler = (event, context, callback) => {
let data = multipart.parse(event, true);
fs.writeFile('test.webm', data.file.content, 'binary', function(err) {
if(err) {
console.log(err);
} else {
console.log('saved');
}
});
};
+1 running into the same issue, incorrect buffer causing corrupted file
Seems to be a problem on serverless offline's end. Refer to this issue.
@Tutch I applied the changes referenced in that issue and got it working :thumbsup:
@Tutch @sparent what are changes helped you?
@myshenin the solution in this issue right here solved the problem. But there's no need to worry anymore, because serverless-offline accepted the solution on this merge request here. The current version of serverless-offline works as expected with this multiparser.
@Tutch as I understood the issue is in encoding? I tried to fix it with toString('binary') but it didn't work
Unfortunately, there is an issue with malformed media files uploaded to S3. Let me explain on example, I send an image, which is 50Kb. I get a buffer, which is 50Kb. That fact indicates buffer is formed well, but some encoding issue happens with s3.upload and s3.putObject functions. If you have a solution or a hint, contact me myshenin.contact@gmail.com. @Tutch @sparent @davidgatti
@djgovani I tried your implementation for pdf files and it didn't help. Does anyone have another idea?
I'm running in this situation where the buffer that I get back from this module, is not correct. For example images won't be displayed because of this. It seams to me that your code is parsing the binary data from the request incorrectly.