【发布时间】:2019-03-01 14:46:17
【问题描述】:
gcloud beta functions deploy gcp-data-transfer --project probable-scout-216702 --runtime python37 --trigger-bucket connector-test-data-securonix --entry-point detect_file
以上是我正在使用的谷歌云功能。这是我的谷歌云存储桶上的触发器。我的 gcloud 功能正在运行,但我不知道文件应该下载到哪里。我能够将它存储在 /tmp/ 目录中,但它仍然不在我自己的系统上,我不知道哪个 /tmp 它正在下载。我正在使用以下代码:
def detect_file(file, context):
destination_file_name = "/Securonix/file1.txt"
f = open("/Securonix/file1.txt",'wb')
bucket = validate_message(file, 'bucket')
name = validate_message(file, 'name')
print("here")
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket)
blob = bucket.blob(name)
blob.download_to_file(f)
print('Blob {} downloaded to {}.'.format(
name,
destination_file_name))
def validate_message(message, param):
var = message.get(param)
if not var:
raise ValueError('{} is not provided. Make sure you have \
property {} in the request'.format(param, param))
return var
我收到错误:
FileNotFoundError: [Errno 2] No such file or directory: '/Securonix/file1.txt'
【问题讨论】:
标签: google-cloud-platform blob google-cloud-storage google-cloud-functions