我已经成功实现了将文件上传到 Google Cloud Storage 存储桶的 python 函数,但我想将它添加到存储桶中的子目录(文件夹),当我尝试将它添加到存储桶名称时,代码找不到文件夹。
谢谢!
def upload_blob(bucket_name, source_file_name, destination_blob_name):
"""Uploads a file to the bucket."""
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket_name +"/folderName") #I tried to add my folder here
blob = bucket.blob(destination_blob_name)
blob.upload_from_filename(source_file_name)
print('File {} uploaded to {}.'.format(
source_file_name,
destination_blob_name))