Fix missing timeout value in object storage pre-authorization call
This commit is contained in:
parent
4c74936f45
commit
a23ef89e57
3 changed files with 10 additions and 1 deletions
|
@ -11,6 +11,7 @@ module ObjectStorage
|
|||
ObjectStorageUnavailable = Class.new(StandardError)
|
||||
|
||||
DIRECT_UPLOAD_TIMEOUT = 4.hours
|
||||
DIRECT_UPLOAD_EXPIRE_OFFSET = 15.minutes
|
||||
TMP_UPLOAD_PATH = 'tmp/uploads'.freeze
|
||||
|
||||
module Store
|
||||
|
@ -174,11 +175,12 @@ module ObjectStorage
|
|||
id = [CarrierWave.generate_cache_id, SecureRandom.hex].join('-')
|
||||
upload_path = File.join(TMP_UPLOAD_PATH, id)
|
||||
connection = ::Fog::Storage.new(self.object_store_credentials)
|
||||
expire_at = Time.now + DIRECT_UPLOAD_TIMEOUT
|
||||
expire_at = Time.now + DIRECT_UPLOAD_TIMEOUT + DIRECT_UPLOAD_EXPIRE_OFFSET
|
||||
options = { 'Content-Type' => 'application/octet-stream' }
|
||||
|
||||
{
|
||||
ID: id,
|
||||
Timeout: DIRECT_UPLOAD_TIMEOUT,
|
||||
GetURL: connection.get_object_url(remote_store_path, upload_path, expire_at),
|
||||
DeleteURL: connection.delete_object_url(remote_store_path, upload_path, expire_at),
|
||||
StoreURL: connection.put_object_url(remote_store_path, upload_path, expire_at, options)
|
||||
|
|
5
changelogs/unreleased/fix-missing-timeout.yml
Normal file
5
changelogs/unreleased/fix-missing-timeout.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Missing timeout value in object storage pre-authorization
|
||||
merge_request: 19201
|
||||
author:
|
||||
type: fixed
|
|
@ -382,6 +382,8 @@ describe ObjectStorage do
|
|||
is_expected.to have_key(:RemoteObject)
|
||||
|
||||
expect(subject[:RemoteObject]).to have_key(:ID)
|
||||
expect(subject[:RemoteObject]).to include(Timeout: a_kind_of(Integer))
|
||||
expect(subject[:RemoteObject][:Timeout]).to be(ObjectStorage::DIRECT_UPLOAD_TIMEOUT)
|
||||
expect(subject[:RemoteObject]).to have_key(:GetURL)
|
||||
expect(subject[:RemoteObject]).to have_key(:DeleteURL)
|
||||
expect(subject[:RemoteObject]).to have_key(:StoreURL)
|
||||
|
|
Loading…
Reference in a new issue