Skip to content

Commit 5dcfb42

Browse files
committed
feat: 🎸 support httpRequest promise for upload
✅ Closes: #1100
1 parent b6dd882 commit 5dcfb42

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

‎src/components/upload/upload.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@
147147
webkitdirectory: {
148148
type: Boolean,
149149
default: false
150-
}
150+
},
151+
httpRequest: {
152+
type: Function,
153+
default: ajax
154+
},
151155
},
152156
data () {
153157
return {
@@ -250,7 +254,7 @@
250254
let formData = new FormData();
251255
formData.append(this.name, file);
252256
253-
ajax({
257+
const options = {
254258
headers: this.headers,
255259
withCredentials: this.withCredentials,
256260
file: file,
@@ -266,7 +270,11 @@
266270
onError: (err, response) => {
267271
this.handleError(err, response, file);
268272
}
269-
});
273+
};
274+
const req = this.httpRequest(options);
275+
if (req && req.then) {
276+
req.then(options.onSuccess, options.onError);
277+
}
270278
},
271279
handleStart (file) {
272280
file.uid = Date.now() + this.tempIndex++;

0 commit comments

Comments
 (0)