Skip to content

Commit

Permalink
gcloud: Use DEFAULT_RETRY when uploading a file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Karvonen committed Jul 15, 2022
1 parent 0c5638b commit 3df7083
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion storages/backends/gcloud.py
Expand Up @@ -19,6 +19,7 @@
from google.cloud.exceptions import NotFound
from google.cloud.storage import Blob, Client
from google.cloud.storage.blob import _quote
from google.cloud.storage.retry import DEFAULT_RETRY
except ImportError:
raise ImproperlyConfigured("Could not load Google Cloud Storage bindings.\n"
"See https://github.com/GoogleCloudPlatform/gcloud-python")
Expand Down Expand Up @@ -88,6 +89,7 @@ def close(self):
blob_params = self._storage.get_object_parameters(self.name)
self.blob.upload_from_file(
self.file, rewind=True, content_type=self.mime_type,
retry=DEFAULT_RETRY,
predefined_acl=blob_params.get('acl', self._storage.default_acl))
self._file.close()
self._file = None
Expand Down Expand Up @@ -187,7 +189,7 @@ def _save(self, name, content):
for prop, val in blob_params.items():
setattr(file_object.blob, prop, val)

file_object.blob.upload_from_file(content, rewind=True, size=getattr(content, 'size', None), **upload_params)
file_object.blob.upload_from_file(content, rewind=True, retry=DEFAULT_RETRY, size=getattr(content, 'size', None), **upload_params)
return cleaned_name

def get_object_parameters(self, name):
Expand Down

0 comments on commit 3df7083

Please sign in to comment.