From 89461276fcea7e3f463ee005309960deaac9eb9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com>
Date: Fri, 7 Oct 2022 16:55:42 +0200
Subject: [PATCH] service gem

---
 Gemfile                                       |  1 +
 Gemfile.lock                                  |  4 ++-
 .../service/scaleway_service.rb               | 30 -------------------
 3 files changed, 4 insertions(+), 31 deletions(-)
 delete mode 100644 lib/active_storage/service/scaleway_service.rb

diff --git a/Gemfile b/Gemfile
index 36d27bb11..11caafd9a 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 ac4612cdc..981ccb725 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 28b7569b9..000000000
--- 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
-- 
GitLab