When saving an image to S3 using the AWS Lambda function with PHP, the file is saved as . bin

Asked

Viewed 92 times

0

I have an Laravel app that runs as a Lambda function on AWS. When I upload an image using the S3 driver, the final file is saved with the extension .bin.

I used the method storeAs, to set the file name and maintain the original extension, but when I open the file seems to be corrupted.

The code snippet is currently this.

$file = $request->file('image');
$filename = 'anuncio.' . $file->getClientOriginalExtension();
$file->storeAs('img/anuncios', $filename);

Could you help me?

  • because instead of using the method ... $file->getClientOriginalExtension() Voce does not separate the entire file name using split, something like filename.split('/').pop().split('.')[1]&#Try it, if you don’t solve, warn, if you solve, vote for my comment

  • This method brings the file extension properly. The problem is that when I get this file there in S3, the image does not open. I used a tool that generates a hash of the file. I compared and, the original file is really different than it goes pro S3.

  • I think this will help you https://medium.com/@ediltondanniken/salvaging-your-files-no-Amazon-S3-com-Laravel-f20d389c6185

  • I had already tried. When I do so, that’s when the file goes to S3 with the extension . bin

  • Man, you’d have to see more of your code to get an idea of why you’re saving wrong

  • This started happening after I put it in the AWS Lambda. Before that it was working normally

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.