Skip to content

Batch uploading of files #3139

@tartavull

Description

@tartavull

I'm confused about this comment https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/storage/google/cloud/storage/blob.py#L589

What is the correct way of uploading blobs in a batch?

    client = storage.Client.from_service_account_json('client-secret.json', project=PROJECT_NAME)
    bucket = client.get_bucket(BUCKET_NAME)
    with client.batch():
        for i in range(10):
            with open('base.py', 'rb') as my_file:
                blob = storage.Blob('/test/{}'.format(i), bucket)
                blob.upload_from_file(my_file, client=client)

This, of course, won't work because is using client._base_connection instead of client.current_batch.

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions