parent
a9c64545fa
commit
2b07b6d8a9
5 changed files with 11 additions and 7 deletions
|
@ -46,7 +46,7 @@ class BaseStorage(StoragePaths):
|
|||
client to use for any external calls. """
|
||||
pass
|
||||
|
||||
def get_direct_download_url(self, path, expires_in=60, requires_cors=False):
|
||||
def get_direct_download_url(self, path, expires_in=60, requires_cors=False, head=False):
|
||||
return None
|
||||
|
||||
def get_direct_upload_url(self, path, mime_type, requires_cors=True):
|
||||
|
|
|
@ -116,10 +116,12 @@ class _CloudStorage(BaseStorageV2):
|
|||
def get_supports_resumable_downloads(self):
|
||||
return True
|
||||
|
||||
def get_direct_download_url(self, path, expires_in=60, requires_cors=False):
|
||||
def get_direct_download_url(self, path, expires_in=60, requires_cors=False, head=False):
|
||||
self._initialize_cloud_conn()
|
||||
path = self._init_path(path)
|
||||
k = self._key_class(self._cloud_bucket, path)
|
||||
if head:
|
||||
return k.generate_url(expires_in, 'HEAD')
|
||||
return k.generate_url(expires_in)
|
||||
|
||||
def get_direct_upload_url(self, path, mime_type, requires_cors=True):
|
||||
|
|
|
@ -15,7 +15,7 @@ class FakeStorage(BaseStorageV2):
|
|||
def _init_path(self, path=None, create=False):
|
||||
return path
|
||||
|
||||
def get_direct_download_url(self, path, expires_in=60, requires_cors=False):
|
||||
def get_direct_download_url(self, path, expires_in=60, requires_cors=False, head=False):
|
||||
try:
|
||||
if self.get_content('supports_direct_download') == 'true':
|
||||
return 'http://somefakeurl'
|
||||
|
|
|
@ -114,7 +114,7 @@ class SwiftStorage(BaseStorage):
|
|||
logger.exception('Could not head object: %s', path)
|
||||
return None
|
||||
|
||||
def get_direct_download_url(self, object_path, expires_in=60, requires_cors=False):
|
||||
def get_direct_download_url(self, object_path, expires_in=60, requires_cors=False, head=False):
|
||||
if requires_cors:
|
||||
return None
|
||||
|
||||
|
@ -137,7 +137,7 @@ class SwiftStorage(BaseStorage):
|
|||
object_path = self._normalize_path(object_path)
|
||||
|
||||
# Generate the signed HMAC body.
|
||||
method = 'GET'
|
||||
method = 'HEAD' if head else 'GET'
|
||||
expires = int(time() + expires_in)
|
||||
full_path = '%s/%s/%s' % (path, self._swift_container, object_path)
|
||||
|
||||
|
|
Reference in a new issue