在Google云端存储中创建的动态子文件夹

时间:2018-07-25 11:40:34

标签: dynamic structure google-cloud-storage directory

1)我希望通过gsutil或python在Google云存储中创建动态文件夹和子文件夹结构。每当用户在Web门户中创建job_id时,都应创建以下文件夹结构。 例如, ** $ BUCKET / CV / $ JOB_ID $ BUCKET / JD / $ JOB_ID
$ BUCKET /报告/ $ JOB_ID 2)我可以在python NLP脚本中使用这些动态文件路径来处理算法。

1 个答案:

答案 0 :(得分:0)

使用您已有的代码,您可以执行以下操作:

from google.cloud import storage 
def upload_blob(bucket_name, source_file_name, destination_blob_name, api_parameter): 
"""Uploads a file to the bucket.""" 
    storage_client = storage.Client() 
    bucket = storage_client.get_bucket(bucket_name) 
    blob = bucket.blob("{}/".format(api_parameter) + destination_blob_name) 

其中api_parameter是您提到的API中的查询参数。

相关问题