Skip to content

Commit 10190a3

Browse files
authored
Merge pull request #375 from Sakura0408/dev
upload配置项添加额外请求参数
2 parents c7c8838 + 06b1921 commit 10190a3

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/ts/upload/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ const uploadFiles = (vditor: IVditor, files: FileList | DataTransferItemList | F
199199
formData.append("file[]", validateResult[i]);
200200
}
201201

202+
const extraData = vditor.options.upload.extraData;
203+
for (const key of Object.keys(extraData)) {
204+
// @ts-ignore
205+
formData.append(key, extraData[key]);
206+
}
207+
202208
const xhr = new XMLHttpRequest();
203209
xhr.open("POST", vditor.options.upload.url);
204210
if (vditor.options.upload.token) {

types/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ interface IUpload {
226226
withCredentials?: boolean;
227227
/** 请求头设置 */
228228
headers?: { [key: string]: string };
229+
/** 额外请求参数 */
230+
extraData?: object;
229231

230232
/** 每次上传前都会重新设置请求头 */
231233
setHeaders?(): { [key: string]: string };

0 commit comments

Comments
 (0)