Python 3.x 如何使用curl将文件发送到googlecloud函数?
我有以下主要基于文档的云功能:Python 3.x 如何使用curl将文件发送到googlecloud函数?,python-3.x,curl,google-cloud-functions,Python 3.x,Curl,Google Cloud Functions,我有以下主要基于文档的云功能: def hello_world(request): if request.method == 'GET': print('GET') elif request.method == 'PUT': print("PUT") # This code will process each file uploaded files = request.files.to_dict() print("files
def hello_world(request):
if request.method == 'GET':
print('GET')
elif request.method == 'PUT':
print("PUT")
# This code will process each file uploaded
files = request.files.to_dict()
print("files: ",files)
for file_name, file in files.items():
file.save(get_file_path(file_name))
print('Processed file: %s' % file_name)
# Clear temporary directory
for file_name in files:
file_path = get_file_path(file_name)
os.remove(file_path)
return "Done!"
使用以下curl命令,我尝试将文件上载到此函数,该文件可以是图像或pdf:
curl-i-T myFile-verbose
执行此操作时,我的函数将打印PUT并立即返回Done。因此,文件字典是空的
有人能帮我吗?你应该能做类似的事情: 卷曲\ -表单file1=@filename1\ -表单file2=@filename2\ ...\ https://... 另一种可能更好的解决方案是将文件直接发布到谷歌云存储,然后触发云功能处理这些文件,这些文件可能也从源|接收桶移动到目标|处理桶: 小调:我认为,在这种情况下,POST比PUT更可取