Commit 67c7f6f1 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'bjk/22390_google_warning' into 'master'

Fix object storage deprecation warning

Closes #22390

See merge request gitlab-org/gitlab!17483
parents 36bed425 c1c2ba4b
......@@ -92,8 +92,12 @@ module ObjectStorage
# Implements https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html
def get_url
if google?
connection.get_object_https_url(bucket_name, object_name, expire_at)
else
connection.get_object_url(bucket_name, object_name, expire_at)
end
end
# Implements https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html
def delete_url
......@@ -166,6 +170,10 @@ module ObjectStorage
provider == 'AWS'
end
def google?
provider == 'Google'
end
def requires_multipart_upload?
aws? && !has_length
end
......
......@@ -60,6 +60,38 @@ describe ObjectStorage::DirectUpload do
end
end
describe '#get_url' do
subject { described_class.new(credentials, bucket_name, object_name, has_length: true) }
context 'when AWS is used' do
it 'calls the proper method' do
expect_next_instance_of(::Fog::Storage, credentials) do |connection|
expect(connection).to receive(:get_object_url).once
end
subject.get_url
end
end
context 'when Google is used' do
let(:credentials) do
{
provider: 'Google',
google_storage_access_key_id: 'GOOGLE_ACCESS_KEY_ID',
google_storage_secret_access_key: 'GOOGLE_SECRET_ACCESS_KEY'
}
end
it 'calls the proper method' do
expect_next_instance_of(::Fog::Storage, credentials) do |connection|
expect(connection).to receive(:get_object_https_url).once
end
subject.get_url
end
end
end
describe '#to_hash' do
subject { direct_upload.to_hash }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment