spree_api_examples icon indicating copy to clipboard operation
spree_api_examples copied to clipboard

paperclip reports spoofed image file type for some images

Open Qwertie- opened this issue 7 years ago • 0 comments

While uploading images I found that some of them were failing to upload with the error Content Type Spoof: Filename local.path (image/jpeg from Headers, [] from Extension), content type discovered from file command: image/jpeg. See documentation to allow this combination.

I found that adding the file name while uploading fixed this issue

file_name = File.basename(image_path)
attachment = Faraday::UploadIO.new(image, file_type, file_name)

Not sure if you want to add this in to the example code, shouldn't ever hurt to send the file name but this should at least help someone with the same issue.

Qwertie- avatar Jun 30 '17 01:06 Qwertie-