diff --git a/google/cloud/storage/blob.py b/google/cloud/storage/blob.py index f47c09181..205d4aeb2 100644 --- a/google/cloud/storage/blob.py +++ b/google/cloud/storage/blob.py @@ -2456,7 +2456,7 @@ def upload_from_file( to that project. :type file_obj: file - :param file_obj: A file handle open for reading. + :param file_obj: A file handle opened in binary mode for reading. :type rewind: bool :param rewind: diff --git a/samples/snippets/storage_upload_from_stream.py b/samples/snippets/storage_upload_from_stream.py index e2d31a5e3..08eb25889 100644 --- a/samples/snippets/storage_upload_from_stream.py +++ b/samples/snippets/storage_upload_from_stream.py @@ -25,8 +25,8 @@ def upload_blob_from_stream(bucket_name, file_obj, destination_blob_name): # The stream or file (file-like object) from which to read # import io - # file_obj = io.StringIO() - # file_obj.write("This is test data.") + # file_obj = io.BytesIO() + # file_obj.write(b"This is test data.") # The desired name of the uploaded GCS object (blob) # destination_blob_name = "storage-object-name"