I am trying to learn how to upload files in a bucket on Google Cloud Storage. I found this code: https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/storage/cloud-client This can do a bunch of operations like create-bucket, delete-bucket, list, upload and download …
But, I am unable to run the code.
I tried:
python snippets.py [-h] scene.appspot.com list
Error:
error: argument command: invalid choice: 'scene-maker.appspot.com' (choose from 'create-bucket', 'delete-bucket', 'get-bucket-labels', 'add-bucket-label', 'remove-bucket-label', 'list', 'list-with-prefix', 'upload', 'download', 'delete', 'metadata', 'make-public', 'signed-url', 'rename', 'copy')
I tried:
python snippets.py [-h] list scene.appspot.com
python snippets.py [-h] list gs://scene.appspot.com
python snippets.py [-h] list "gs://scene.appspot.com"
python snippets.py [-h] list bucket_name
Error:
error: unrecognized arguments: scene.appspot.com
error: unrecognized arguments: gs://scene.appspot.com
I tried:
python snippets.py list [-h] scene.appspot.com
Error:
error: argument command: invalid choice: '[-h]' (choose from 'create-bucket', 'delete-bucket', 'get-bucket-labels', 'add-bucket-label', 'remove-bucket-label', 'list', 'list-with-prefix', 'upload', 'download', 'delete', 'metadata', 'make-public', 'signed-url', 'rename', 'copy')
I tried:
python snippets.py [-h] list
Error:
Traceback (most recent call last):
File "snippets.py", line 322, in <module>
list_blobs(args.bucket_name)
File "snippets.py", line 88, in list_blobs
bucket = storage_client.get_bucket(bucket_name)
File "C:\Anaconda2\lib\site-packages\google\cloud\storage\client.py", line 172, in get_bucket
bucket = Bucket(self, name=bucket_name)
File "C:\Anaconda2\lib\site-packages\google\cloud\storage\bucket.py", line 113, in __init__
name = _validate_name(name)
File "C:\Anaconda2\lib\site-packages\google\cloud\storage\_helpers.py", line 39, in _validate_name
'Bucket names must start and end with a number or letter.')
ValueError: Bucket names must start and end with a number or letter.
When I run: gsutil ls
I get:
gs://scene.appspot.com/
gs://staging.scene.appspot.com/
How to use python snippets.py
command?
Ultimately, I want users to be able to upload files form a web browser to Cloud Storage.