Skip to content

Can you add support to cos of tencent cloud? #660

@james-li

Description

@james-li

When I setup a gitlab server in tencent cloud and want to use the cos(object storage) to store upload artificate. COS uses a different api for put object.

PUT /<ObjectKey> HTTP/1.1
Host: <BucketName-APPID>.cos.<Region>.myqcloud.com
Date: GMT Date
x-cos-copy-source: <SourceBucketName-SourceAPPID>.cos.<SourceRegion>.myqcloud.com/<SourceObjectKey>
Content-Length: 0
Authorization: Auth String

So I have to modify fog-aws-3.14.0/lib/fog/aws/storage.rb, add following to work around.

diff --git a/lib/fog/aws/storage.rb b/lib/fog/aws/storage.rb
index 73e72aef1..6603ea2f7 100644
--- a/lib/fog/aws/storage.rb
+++ b/lib/fog/aws/storage.rb
@@ -629,7 +627,9 @@ module Fog
           host = params.delete(:host)
           port = params.delete(:port) || DEFAULT_SCHEME_PORT[scheme]
           params[:headers]['Host'] = host
-
+          if host.downcase =~ (/.*myqcloud.com.*/) && params[:headers]["x-amz-copy-source"] != nil
+            params[:headers]["x-amz-copy-source"] = "#{host}#{params[:headers]["x-amz-copy-source"]}"
+          end

           if @signature_version == 4
             params[:headers]['x-amz-date'] = date.to_iso8601_basic

It works but is very ugly. :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions