-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
上传多文件失败 #36
Comments
默认情况下,提交数据对象内包含 |
apiDeviceFilesPost<
Config extends Alova2MethodConfig<RESTfulResult_String> & {
data: {
files?: Blob[];
};
}
>(
config: Config
): Alova2Method<RESTfulResult_String, 'device.apiDeviceFilesPost', Config>; 上传单文件,会自动包装成formdata。 |
@Pomelo2021 你是指你的接口传的是一个文件数组,然后导致失败的对吗 |
对啊,传的数组,就不会自动包装成formdata了 if (Object.prototype.toString.call(data) === '[object Object]' && typeof FormData !== 'undefined') {
let hasBlobData = false;
const formData = new FormData();
for (const key in data) {
formData.append(key, data[key]);
if (data[key] instanceof Blob) {
hasBlobData = true;
}
}
data = hasBlobData ? formData : data;
} |
好的,我们优化下 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如下,生成api代码修改后成功,仅供参考,我js很菜
The text was updated successfully, but these errors were encountered: