I have create a method that transfers a set amount of images from a called folder through google cloud storage, however when running it creates the directory but does not transfer any images
def Cloud_Transfer(UserLabel, UserCounter):
storage_client = storage.Client()
gcs_bucket_store = 'export'
gcs_bucket_upload = 'active'
counter_limit = UserCounter
label = UserLabel
label_prefix = 'verified images/' + label + '/'
source_bucket = storage_client.get_bucket(gcs_bucket_store)
blobs = source_bucket.list_blobs(prefix = label_prefix)
counter = 0
for blob in blobs:
if counter == counter_limit:
print("Done")
else:
source_blob = source_bucket.blob(blob.name)
destination_bucket = storage_client.get_bucket(gcs_bucket_upload)
new_blob = source_bucket.copy_blob(source_blob, destination_bucket, blob.name)
counter += 1
return counter
the images are located in a path "verified images/"label"/image.jpg" I expect this file to be transferred across however only end up with the path and no image copied
This links are examples of how to perform basic operations on blobs (objects) in a Google Cloud Storage bucket:
https://cloud.google.com/storage/docs/creating-buckets#storage-create-bucket-code_samples
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.