diff --git a/Gemfile b/Gemfile index 36d27bb11e07ee34c989dbb42b2d8b282759ff52..11caafd9a003c4f9496e986685ab7d80223749b2 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.7.6' # Infrastructure +gem 'activestorage-scaleway-service'#, path: '../activestorage-scaleway-service' gem 'angularjs-rails' gem 'aws-sdk-s3' gem 'bootsnap', '>= 1.4.4', require: false diff --git a/Gemfile.lock b/Gemfile.lock index ac4612cdc381a85fda0f3457609b91f64488bb82..981ccb7259c2e926ca91bdaeee30d3d5d7bd9c5f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,6 +74,7 @@ GEM activesupport (= 6.1.7) marcel (~> 1.0) mini_mime (>= 1.1.0) + activestorage-scaleway-service (1.0.0) activesupport (6.1.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) @@ -480,6 +481,7 @@ PLATFORMS x86_64-linux DEPENDENCIES + activestorage-scaleway-service angularjs-rails annotate aws-sdk-s3 @@ -544,4 +546,4 @@ RUBY VERSION ruby 2.7.6p219 BUNDLED WITH - 2.3.12 + 2.3.22 diff --git a/lib/active_storage/service/scaleway_service.rb b/lib/active_storage/service/scaleway_service.rb deleted file mode 100644 index 28b7569b96cf8bf5149497c361c1ae19f7a2c17b..0000000000000000000000000000000000000000 --- a/lib/active_storage/service/scaleway_service.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -# cf https://github.com/rails/rails/issues/41070 - -require 'active_storage/service/s3_service.rb' - -module ActiveStorage - class Service::ScalewayService < Service::S3Service - - def headers_for_direct_upload(key, content_type:, checksum:, filename: nil, disposition: nil, **) - content_disposition = content_disposition_with(type: disposition, filename: filename) if filename - - headers = public? ? { "x-amz-acl" => "public-read" } : {} - - headers.merge({ "Content-Type" => content_type, "Content-MD5" => checksum, "Content-Disposition" => content_disposition }) - end - - private - - def public_url(key, **options) - disposition, filename, content_type = options.values_at(:disposition, :filename, :content_type) - uri = URI.parse(object_for(key).public_url) - uri.query = URI.encode_www_form({ - "response-content-disposition" => content_disposition_with(type: disposition, filename: filename), - "response-content-type" => content_type - }) - uri.to_s - end - end -end