-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uploader 文件上传组件,如何请求将参数置于文件前面 #104
Labels
Comments
可以自实现 |
感谢提醒,我尝试一下。 |
我找到那段代码了,请问是否可以在UploaderOptions添加一个参数:parametersBeforeFiles:boolean,用于判断是否前置请求参数,代码实现,我查看了另一个文件上传的框架。 if (!this._options.disableMultipart) {
sendable = new FormData();
sendable.append(item.options.alias, item._file, item.file.name);
if (this._options.params !== undefined) {
Object.keys(this._options.params).forEach((key) => {
sendable.append(key, this._options.params[key]);
});
}
} 添加参数后,建议修改的代码: if (!this._options.disableMultipart) {
sendable = new FormData();
if (!this._options.parametersBeforeFiles) {
sendable.append(item.options.alias, item._file, item.file.name);
}
if (this._options.params !== undefined) {
Object.keys(this._options.params).forEach((key) => {
sendable.append(key, this._options.params[key]);
});
}
if (this._options.parametersBeforeFiles) {
sendable.append(item.options.alias, item._file, item.file.name);
}
} 只需要在您的代码前后各加一个if判断即可,因为很多oss文件直传都要求请求的参数在文件之前。请问是否可以修改? |
没有必要判断,请求参数在文件之前也算是合理的方式。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请问如何将请求参数置于文件参数前面,
当前请求效果:
------WebKitFormBoundaryOgWcG03kfr8fFPps
Content-Disposition: form-data; name="file"; filename="xsdfadfasdfas.pic_hd.jpg"
Content-Type: image/jpeg
------WebKitFormBoundaryOgWcG03kfr8fFPps
Content-Disposition: form-data; name="xxx"
xxxxxxxxxx
------WebKitFormBoundaryOgWcG03kfr8fFPps
Content-Disposition: form-data; name="kkk"
kkkkk
期望效果:
------WebKitFormBoundaryOgWcG03kfr8fFPps
Content-Disposition: form-data; name="xxx"
xxxxxxxxxx
------WebKitFormBoundaryOgWcG03kfr8fFPps
Content-Disposition: form-data; name="kkk"
kkkkk
------WebKitFormBoundaryOgWcG03kfr8fFPps
Content-Disposition: form-data; name="file"; filename="xsdfadfasdfas.pic_hd.jpg"
Content-Type: image/jpeg
The text was updated successfully, but these errors were encountered: