QUploader Trigger updateProgress From Outside upload-factory
-
How can we trigger updateProgress from outside the upload-factory.
Update progress listener is outside the upload-factory, so how can we call the updateprogress for the file.
Can anyone suggest a solution
-
do you have some code to show?
-
Yes, sure. Thanks for your response.
In the Vue file
<q-uploader
ref=“listUploader”
:url=“url”
:upload-factory=“uploadFile”
…<script>
import client from “src/api/client”;const uploadService = client.service(“uploads”);
// UPLOAD PROGRESS LISTENER, PROGRESS RECEIVED FROM FEATHERSJS (socketio)
uploadService.on(“uploadProgress”, eventData => {
debug("@uploadProgress ", eventData);
});// UPLOAD FACTORY
methods: {
uploadFile(file, updateProgress) {
const fileSize = file.size;
// HERE NEED TO CALL updateProgress(PROGRESS)
…
} -
have your tried using $refs ?
-
Fixed. I ended up moving the event listener inside the upload-factory.
uploadFile(file, updateProgress) { // updateProgress(0.5); const applyProgress = eventData => { ... updateProgress(progressPercent); } }; uploadService.on("uploadProgress", applyProgress); return new Promise((resolve, reject) => { this.$axios .post("/uploads", formData) .then(response => { uploadService.removeListener("uploadProgress"); return resolve(file); }) .catch(err => { ... return reject(err); } }); }