gpt4 book ai didi

javascript - 为什么 Flask 没有收到我的 POST Blob?

转载 作者:行者123 更新时间:2023-11-29 10:42:52 25 4
gpt4 key购买 nike

我的问题是我用 FormData 向服务器发送了一个 Blob,但服务器没有收到它。代码如下所示:

flask 服务器代码:

@app.route('/save-record', methods=['POST'])
def save_record():
app.logger.debug(request.form.keys()) #Shows only the title key, not the file key

客户端 JS 代码:

var save = function() {
var form = new FormData();
form.append('file', record.blob, record.filename);
form.append('title', searchedObj.title);
//Chrome inspector shows that the post data includes a file and a title.
$.ajax({
type: 'POST',
url: '/save-record',
data: form,
cache: false,
processData: false,
contentType: false
}).done(function(data) {
console.log(data);
});

最佳答案

检查 request.files 文件。

@app.route('/save-record', methods=['POST'])
def save_record():
app.logger.debug(request.files['file'].filename)

关于javascript - 为什么 Flask 没有收到我的 POST Blob?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25345154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com