lib/saviour/s3_storage.rb in saviour-0.6.9 vs lib/saviour/s3_storage.rb in saviour-0.6.10
- old
+ new
@@ -1,10 +1,12 @@
begin
require 'aws-sdk-s3'
rescue LoadError
end
+require 'marcel'
+
module Saviour
class S3Storage
MissingPublicUrlPrefix = Class.new(StandardError)
KeyTooLarge = Class.new(StandardError)
@@ -25,11 +27,15 @@
# http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
if path.bytesize > 1024
raise(KeyTooLarge, "The key in S3 must be at max 1024 bytes, this key is too big: #{path}")
end
+ mime_type = Marcel::MimeType.for file_or_contents
+
# TODO: Use multipart api
- client.put_object(@create_options.merge(body: file_or_contents, bucket: @bucket, key: path))
+ client.put_object(@create_options.merge(
+ body: file_or_contents, bucket: @bucket, key: path, content_type: mime_type
+ ))
end
def write_from_file(file, path)
file.rewind