curl命令从flask的输入表单中上传文件列表的命令是什么?

时间:2018-06-22 12:36:39

标签: python curl flask

我需要curl命令从表单文件输入字段上载文件列表。我尝试过的:

curl -b cookies.txt -X POST http://localhost:8081/rt/api/v1.0/add -d '{"title":"Website updated", "description": "Not accessible", "requestor":"abc@ytz.com", "mfiles":["file1.txt","file2.txt"]}' -H 'Content-type:Application/json'

上传文件的api:

  for f in request.files.getlist('mfiles'):
        filename = secure_filename(f.filename)
        f.save(os.path.join(upload_folder, filename))

这给了我错误:Statement is not an insert() expression construct.

确切的卷曲度是什么?我正在使用Flask 0.12,python 2.7

1 个答案:

答案 0 :(得分:0)

@鲍里斯,是的。我应该使用输入表格。用于上传多个文件的curl是:

curl -b cookies.txt -X POST http://localhost:8081/rt/api/v1.0/add -F "title=some title MM" -F "description=Not accessible" -F "mfiles=@crons.txt" -F "mfiles=@temp.txt" -F "mfiles=@duplicates.txt"