No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    QUploader Trigger updateProgress From Outside upload-factory

    Help
    2
    5
    938
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      stuffy last edited by

      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

      1 Reply Last reply Reply Quote 0
      • M
        Max last edited by

        do you have some code to show?

        1 Reply Last reply Reply Quote 0
        • S
          stuffy last edited by

          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)
          …
          }

          1 Reply Last reply Reply Quote 0
          • M
            Max last edited by

            have your tried using $refs ?

            1 Reply Last reply Reply Quote 0
            • S
              stuffy last edited by

              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);
              		  }	  
              	  });
              	}
              
              1 Reply Last reply Reply Quote 0
              • First post
                Last post