Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon S3 get file without extension

I'm uploading multiple pictures with different extensions (jpg, png...etc) via java Amazon TransferManager.

for example : picture1.png, picture2.jpg. I would like to serve the content without the extension, a get request to folder/picture1 would return picture1.png.

The client is an angularJs application

Previously, I was hosting all these picture on EC2 and serving it via APACHE with option Multiviews, is there something similar we can do with AmazonS3 ?

Thanks

like image 822
daley Avatar asked Dec 08 '22 21:12

daley


1 Answers

It doesn't work that way. S3 does not impute special meaning to any portion of the object key (path + filename), so it has no concept of "extensions." (Technically, S3 has no real concept of "paths" either, but it behaves in most cases as though it does).

Of course, on the web, file extensions should have no meaning anyway -- the Content-Type declared should be the only thing that matters, so... technically... there's no need for objects in S3 to be saved with their extension.

Save the files to S3 without the extension, set the Content-Type correctly, and you'll have exactly the behavior you're looking for.

like image 188
Michael - sqlbot Avatar answered Jan 24 '23 22:01

Michael - sqlbot