我正在尝试从https://stackoverflow.com/questions/5981990axios
的灵感上传多个文件。
相关代码如下
var bodyFormData = new FormData();
e.files.forEach(file=>{bodyFormData.append(file.name, file.raw());})
axios({
headers: {
'Content-Type': 'multipart/form-data'
},
method: 'post',
url:url,
data:bodyFormData,
}).then(res => {
console.log(res)
});
e
详细是
e.files[1].raw
File {uid: 1631095898088, name: 'history_data_table.pkl', lastModified: 1630656799951, lastModifiedDate: Fri Sep 03 2021 16:13:19 GMT+0800 (China Standard Time), webkitRelativePath: '', …}
e.files[0].raw
File {uid: 1631095893918, name: 'rc_table.pkl', lastModified: 1630656799953, lastModifiedDate: Fri Sep 03 2021 16:13:19 GMT+0800 (China Standard Time), webkitRelativePath: '', …}
但我没有收到预期的数据在这里我使用框架falcon
。相关功能是
class Upload():
def on_post(self, req, resp):
form = req.get_media()
for part in form:
if part.name.split('.')[-1] == 'pkl':
data = part.stream.read()
# print(data) outputs '[object Object]'
我希望数据具有<class 'bytes'>
代表相应文件内容的类型。