我正在尝试使用多部分表单将音频文件上传到Golang服务器.但是,Go返回错误:
multipart: NextPart: bufio: buffer full
我相信这表明我的Javascript请求在多部分格式中没有.这是我的Javascript:
function UploadFile(file) {
var xhr = new XMLHttpRequest();
if (file.type == "audio/mpeg" && file.size <= $id("MAX_FILE_SIZE").value) {
// start upload
var boundary = '---------------------------' + Math.floor(Math.random()*32768) + Math.floor(Math.random()*32768) + Math.floor(Math.random()*32768);
xhr.open("POST", $id("upload").action, true);
xhr.setRequestHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
xhr.setRequestHeader("X_FILENAME", file.name);
xhr.send(file);
}
}
这是我的Golang服务器处理程序:
func FileHandler(w http.ResponseWrit