Skip to content

Commit a0df78a

Browse files
committed
Merge pull request #327 from tseaver/162-document-key-upload-overwrite-semantics
Fix #162: Document semantics of upload to existing key.
2 parents f33e557 + 0eefb21 commit a0df78a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

gcloud/storage/key.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,18 @@ def upload_from_file(self, file_obj, rewind=False, size=None,
214214
content_type=None):
215215
"""Upload the contents of this key from a file-like object.
216216
217+
.. note::
218+
219+
The effect of uploading to an existing key depends on the
220+
"versioning" and "lifecycle" policies defined on the key's
221+
bucket. In the absence of those policies, upload will
222+
overwrite any existing contents.
223+
224+
See the `object versioning
225+
<https://cloud.google.com/storage/docs/object-versioning>`_ and
226+
`lifecycle <https://cloud.google.com/storage/docs/lifecycle>`_
227+
API documents for details.
228+
217229
:type file_obj: file
218230
:param file_obj: A file handle open for reading.
219231
@@ -276,6 +288,18 @@ def upload_from_file(self, file_obj, rewind=False, size=None,
276288
def upload_from_filename(self, filename):
277289
"""Upload this key's contents from the content of f named file.
278290
291+
.. note::
292+
293+
The effect of uploading to an existing key depends on the
294+
"versioning" and "lifecycle" policies defined on the key's
295+
bucket. In the absence of those policies, upload will
296+
overwrite any existing contents.
297+
298+
See the `object versioning
299+
<https://cloud.google.com/storage/docs/object-versioning>`_ and
300+
`lifecycle <https://cloud.google.com/storage/docs/lifecycle>`_
301+
API documents for details.
302+
279303
:type filename: string
280304
:param filename: The path to the file.
281305
"""
@@ -290,6 +314,18 @@ def upload_from_filename(self, filename):
290314
def upload_from_string(self, data, content_type='text/plain'):
291315
"""Upload contents of this key from the provided string.
292316
317+
.. note::
318+
319+
The effect of uploading to an existing key depends on the
320+
"versioning" and "lifecycle" policies defined on the key's
321+
bucket. In the absence of those policies, upload will
322+
overwrite any existing contents.
323+
324+
See the `object versioning
325+
<https://cloud.google.com/storage/docs/object-versioning>`_ and
326+
`lifecycle <https://cloud.google.com/storage/docs/lifecycle>`_
327+
API documents for details.
328+
293329
:type data: string
294330
:param data: The data to store in this key.
295331

0 commit comments

Comments
 (0)