Skip to content
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

feat: 🎸 support httpRequest promise for upload #1102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: 🎸 support httpRequest promise for upload
Closes: #1100
ZhaoQi99 committed Oct 11, 2022
commit 5dcfb423dd1073557c1d58dde367ecb173b63f26
14 changes: 11 additions & 3 deletions src/components/upload/upload.vue
Original file line number Diff line number Diff line change
@@ -147,7 +147,11 @@
webkitdirectory: {
type: Boolean,
default: false
}
},
httpRequest: {
type: Function,
default: ajax
},
},
data () {
return {
@@ -250,7 +254,7 @@
let formData = new FormData();
formData.append(this.name, file);

ajax({
const options = {
headers: this.headers,
withCredentials: this.withCredentials,
file: file,
@@ -266,7 +270,11 @@
onError: (err, response) => {
this.handleError(err, response, file);
}
});
};
const req = this.httpRequest(options);
if (req && req.then) {
req.then(options.onSuccess, options.onError);
}
},
handleStart (file) {
file.uid = Date.now() + this.tempIndex++;