How to create an empty folder on Google Storage with Google API?

前端 未结 7 2128
攒了一身酷
攒了一身酷 2020-12-15 05:18

How to create an empty folder on Google Storage with Google API? (Assume that / is path separator.)

7条回答
  •  借酒劲吻你
    2020-12-15 05:47

    I got through by "creating" the folder when naming the object to be written.

    storage_client = storage.Client()
    bucket = storage_client.bucket(bucket_name)
    
    blob = bucket.blob("new_folder_name/destination_blob_name")
    
    blob.upload_from_filename(source_file_name)
    

提交回复
热议问题