Closed danrjohnson closed 5 years ago
@danrjohnson Thanks for the report. Have you been able to determine how an image might be assigned the wrong Content-Type
? That's more concerning to me, as S3 (and therefore vip) relies heavily on this value to work properly.
We get the Content-Type
from the request here: https://github.com/vokal/vip/blob/master/handler.go#L171
And that is checked against the decoded format here (at least for JPEGs): https://github.com/vokal/vip/blob/master/handler.go#L222
Relying on the client to send a proper Content-Type
header is a performance optimization. We have some planned fixes in the future that should allow better checking of this, but S3 still requires a Content-Type
for putting it in the bucket for the optimized image serving via CloudFront to work properly anyhowways. Are you having an issue where clients are sending the wrong Content-Type
with the upload? We haven't seen that in the three years we've been using vip.
@foresmac It could very well be that the client is sending along the wrong Content-Type. I'll need to do some further investigation to determine if that is happening. Interestingly enough, one of the reported files was in-fact a jpeg image being assigned the png Content-Type
.
If an image in a bucket has the wrong Content-Type headers set, this will cause the wrong resize method to be called. For instance, if a jpeg has incorrectly been assigned the Content-Type header "image/gif", vip will call ResizeGif when it should call Resize.
This happens at https://github.com/vokal/vip/blob/master/fetch/fetch.go#L87
I figured out a work around here: https://github.com/danrjohnson/vip/commit/9af09774449416b5158f2398a33d881d8821835c
However, I do not have a ton of experience with golang so I'm submitting as an Issue rather than making a pull request.