Why would that happen?
Its ACL permissions are identical to all the other photos.
These photos are hosted via an S3 bucket, but again, there's nothing different than any of the others.
Here is the file URL:
http://s3.amazonaws.com/hq-photo/root/sy开发者_如何学编程stem/images/340/resized_thumb/Osseo-Endo_System.png?1272485279
It's occurring with two images on the same page.
You need to set the mime type. File extensions are not used consistently by browsers.
When you store the file, do something like:
opt = [] # default options for the S3Object.Store call. See the method's
# source for info on all the options
epub = an_epub_file?(obj) # my private method to determine if I'm storing
# an epub file.
extname = File.extname(obj) # Gets the suffix from the file name. Eg ".js"
mimes = MIME::Types.type_for(obj) # if the mime library finds anything, an array
# of mime values is returned
mime = (mimes && mimes[0] && mimes[0].content_type) || # did we get a value from
# the mime library?
( # Nothing from the mime library. Sigh.
# Let's try other ways to get the right mime value...
case
when epub: "application/epub+zip"
when extname == ".js" : "application/x-javascript"
else "application/octet-stream" # default mime value
end)
opt[:content_type] = mime
AWS::S3::S3Object.store(obj, data, bucket, opt)
Note that a case expression is being used in the code example. It is NOT a case statement. A case expression uses the matching arm of the case to return a value.
In the assignment statement above, the case expression is evaluated if the left side of the OR expression ends up false or null.
I used a case expression since I anticipate needing to add other specialized mime types in the future.
精彩评论