gcloud beta functions deploy gcp-data-transfer --project probable-scout-216702 --runtime python37 --trigger-bucket connector-test-data-securonix --entry-point detect_file
Выше я использую облачную функцию Google.это триггер в моем облачном хранилище Google.Моя функция 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'