Handle image paths without extension when uploading
Opened this issue · 7 comments
Some files does not have an extension (latest version of expressjs/multer for instance) which crates a problem for s3-uploader. We should add the ability to pass inn one of the following:
a) the original file name
b) file extension
b) image mime type
client.upload('/some/file', { mime: "image/jpeg" }, function(err, versions, meta) {
...
});
Wouldn't it be better to always detect file format instead since mime type/extensions can be wrong? Seems like identify could help with this.
Good suggestion @oblador, that would definitely be the best option. Would require some more change too I think.
Just tested this and this does not seem to be problem at first sight.
My test was a jpg, without an extension, used as input for s3-uploader.
What did the final URL result in for the original and for a resized image look like?
I thought this line assumed that the original image file name has a file extension.
Well, some of the results have an extension, some do not. So it's a good idea to improve the handling :)
I just looked into the problem again and remembered that this is not as straight forward as it looked like at first glance since each resized image version may have it's own format (versions[#].format
).
We are passing the entire image metadata into resize()
which contains the source image format (results.metadata.format
). I have created Turistforeningen/node-im-resize#8 which makes use of this to make sure that all resized image versions gets a propper file extension.
We have to do something similar here to make sure that the original image gets a correct file extension as well.
Anyone have a working solution?