diff options
Diffstat (limited to 'activestorage')
4 files changed, 23 insertions, 5 deletions
diff --git a/activestorage/lib/active_storage/previewer/poppler_pdf_previewer.rb b/activestorage/lib/active_storage/previewer/poppler_pdf_previewer.rb index 69eb617d7b..6bf501a607 100644 --- a/activestorage/lib/active_storage/previewer/poppler_pdf_previewer.rb +++ b/activestorage/lib/active_storage/previewer/poppler_pdf_previewer.rb @@ -28,7 +28,7 @@ module ActiveStorage private def draw_first_page_from(file, &block) - # use 72 dpi to match thumbnail dimesions of the PDF + # use 72 dpi to match thumbnail dimensions of the PDF draw self.class.pdftoppm_path, "-singlefile", "-r", "72", "-png", file.path, &block end end diff --git a/activestorage/lib/active_storage/service/azure_storage_service.rb b/activestorage/lib/active_storage/service/azure_storage_service.rb index 17cecd891c..993cc0e5f7 100644 --- a/activestorage/lib/active_storage/service/azure_storage_service.rb +++ b/activestorage/lib/active_storage/service/azure_storage_service.rb @@ -10,8 +10,8 @@ module ActiveStorage class Service::AzureStorageService < Service attr_reader :client, :blobs, :container, :signer - def initialize(storage_account_name:, storage_access_key:, container:) - @client = Azure::Storage::Client.create(storage_account_name: storage_account_name, storage_access_key: storage_access_key) + def initialize(storage_account_name:, storage_access_key:, container:, **options) + @client = Azure::Storage::Client.create(storage_account_name: storage_account_name, storage_access_key: storage_access_key, **options) @signer = Azure::Storage::Core::Auth::SharedAccessSignature.new(storage_account_name, storage_access_key) @blobs = client.blob_client @container = container diff --git a/activestorage/lib/active_storage/service/s3_service.rb b/activestorage/lib/active_storage/service/s3_service.rb index 382920ef61..bf94f3f49e 100644 --- a/activestorage/lib/active_storage/service/s3_service.rb +++ b/activestorage/lib/active_storage/service/s3_service.rb @@ -16,9 +16,9 @@ module ActiveStorage @upload_options = upload end - def upload(key, io, checksum: nil, **) + def upload(key, io, checksum: nil, content_type: nil, **) instrument :upload, key: key, checksum: checksum do - object_for(key).put(upload_options.merge(body: io, content_md5: checksum)) + object_for(key).put(upload_options.merge(body: io, content_md5: checksum, content_type: content_type)) rescue Aws::S3::Errors::BadDigest raise ActiveStorage::IntegrityError end diff --git a/activestorage/test/service/s3_service_test.rb b/activestorage/test/service/s3_service_test.rb index 0a6004267f..74c0aa0405 100644 --- a/activestorage/test/service/s3_service_test.rb +++ b/activestorage/test/service/s3_service_test.rb @@ -59,6 +59,24 @@ if SERVICE_CONFIGURATIONS[:s3] service.delete key end end + + test "upload with content type" do + key = SecureRandom.base58(24) + data = "Something else entirely!" + content_type = "text/plain" + + @service.upload( + key, + StringIO.new(data), + checksum: Digest::MD5.base64digest(data), + filename: "cool_data.txt", + content_type: content_type + ) + + assert_equal content_type, @service.bucket.object(key).content_type + ensure + @service.delete key + end end else puts "Skipping S3 Service tests because no S3 configuration was supplied" |