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 likefilename.split('/').pop().split('.')[1]
&#Try it, if you don’t solve, warn, if you solve, vote for my comment– Armando Marques Sobrinho
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.
– Meeeefiu
I think this will help you https://medium.com/@ediltondanniken/salvaging-your-files-no-Amazon-S3-com-Laravel-f20d389c6185
– Armando Marques Sobrinho
I had already tried. When I do so, that’s when the file goes to S3 with the extension . bin
– Meeeefiu
Man, you’d have to see more of your code to get an idea of why you’re saving wrong
– Armando Marques Sobrinho
This started happening after I put it in the AWS Lambda. Before that it was working normally
– Meeeefiu