如何使用 rest client发送http请求携带文件,我使用下面的请求 一直返回无文件上传
//http文件
POST http://127.0.0.1:5000/upload
Accept: */*
Content-Type: multipart/form-data
--null
< E:\123\abc.jpg
--null--
//flask文件
@app.route('/upload', methods=["GET", 'POST'])
def upload():
'''接受上传文件'''
print(request.files)
file_obj = request.files.get("jpg")
if file_obj is None:
# 没有传输数据
return "未上传文件"
else:
with open("./demo.jpg", "wb") as f:
f.write(file_obj.read())
return 'successful'