我有以下HTML表单,将文件上传到服务器
HTML:
<form id="form1" enctype="multipart/form-data" method="post" action="submit">
<input type="file" name="file" accept="text/plain,text/html,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"/>
<div><input id="submit_button" type="submit" value="Upload"/></div>
</form>
在与文件对应的服务器上创建MediaIoBaseUpload
对象的最佳方法是什么?
Python:
def post(self):
file = self.request.POST['file']
# How to create a MediaIoBaseUpload object from file?
答案 0 :(得分:1)
这似乎有效:
media = MediaIoBaseUpload(file.file, mimetype=file.type, resumable=False)