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

    How to use q-uploader to upload a file to Amazon S3

    Help
    4
    4
    712
    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.
    • M
      Mickey58 last edited by

      After realizing that Heroku as the deployment environment for my Quasar app has restrictions with uploading/downloading of files, I’m now looking for some sample code how to use q-uploader to upload files to Amazon S3..

      I’m not familiar with S3 yet and have used q-uploader so far only in a simple way, to upload files to the file system of the Quasar frontend app.

      All I found so far as a boilerplate to start from is a tiny code snippet on the old Quasar site (https://forum.quasar-framework.org/topic/5382/how-to-use-q-uploader-in-quasar-app-deployed-on-heroku ) that uses q-uploader with so called signed S3 URLs.. It uses a q-uploader prop :url-factory=“getSignedUrl”, but I can’t find that prop in the API documentation of the current version of q-uploader on https://quasar.dev/vue-components/uploader#QUploader-API.

      Is there another sample or Codepen how to use q-uploader to upload a file to Amazon S3?

      Would greatly appreciate some advise.

      1 Reply Last reply Reply Quote 3
      • M
        morgler last edited by morgler

        I’m also trying to use QUploader directly to S3 and found the old forum entry. Note that the entry is pretty old and the API of QUploader has changed since. The property is now called :factory (not :factory-url). Still I haven’t managed to get this to work with the current version of Quasar - it would be awesome, if someone could provide an up-to-date code snippet of how to upload to S3 directly using QUploader.

        1 Reply Last reply Reply Quote 0
        • J
          jubalj last edited by jubalj

          The following code works for me - but it is not tidy - I am still getting my head around some js concepts and realise that someone will be able to provide a more concise solution, but seeing as this is unanswered for a couple of years I’ve posted my code. It lets a user upload a single picture upto 5mb, and updates the displayed profile picture from the uploaded image. I have also included the code I use to update the Cognito attributes.

          I also encountered a s3 bucket issue when using amplify solved by https://github.com/aws-amplify/amplify-js/issues/960#issuecomment-421843145

          Below is the code that works for me - Hope this if helpful

          In template:

          <q-uploader ref="uploadedImage" max-file-size="5242880" auto-upload :factory="updatePicture" label="Upload profile picture" accept="image/*"  />
          

          In script:

          function updatePicture(files) {
                pictureURL.value = onFileChange(files).resolve;
              }
              async function onFileChange(files) {
                console.log("uploading")
                const file = files[0];
                //console.dir(files);
                try {
          
             let response = await Storage.put(uid.value + file.name, file, {
                 //acl: "public-read",
                contentType: file.type, // contentType is optional
             });
                  console.log("uploaded");
                  console.log(response);
                  response  = getURL(response.key).then((url) => {
                    console.log("url " + url);
                    return url;
                  });
          
             console.log("Uploaded with URL" + response);
                      return response;
                } catch (error) {
              console.log("Error uploading file: ", error);
            }
              };
          
          async function getURL(key) {
                try {
                  const url = await Storage.get(key);
                  console.log("url from getURL" + url.substring(0,url.lastIndexOf('?')));
                  pictureURL.value = url.substring(0,url.lastIndexOf('?'));
                } catch (error) {
                  console.log("Error getting url: ", error);
                }
          
          

          As a bonus - here is the function I use to update the cognito attributes

          async function  updateProfile() {
                const  user  = await Auth.currentAuthenticatedUser();
                console.log("updating profile " + firstname.value + " " + lastname.value);
                Auth.updateUserAttributes(user, {
                  given_name: firstname.value,
                  family_name: lastname.value,
                  picture: pictureURL.value,
                  name: firstname.value + " " + lastname.value,
                })
                  .then(() => {
                    console.log("updated profile");
                  })
                  .catch((err) => {
                    console.log("error updating profile");
                    console.log(err);
                  });
              };
          
          1 Reply Last reply Reply Quote 0
          • X
            xfinity26 last edited by

            It is possible to perform the second step (checking to find out what the purchase was made with your card) With this option you might be able utilize the information (date date, time, and place of purchase).https://sites.google.com/view/checkwalmartgiftcardbalance/
            https://sites.google.com/targetgiftcardsbalance.com/targetgiftcardbalance/
            https://sites.google.com/view/homedepotgiftcardbalances/
            https://sites.google.com/view/macysgiftcardbalance/
            https://sites.google.com/egiftcard.website/targetcomcheckbalance/
            https://sites.google.com/view/targetgiftcardbalancee/contact-us
            https://sites.google.com/paypalloginus.com/paypal-login/
            https://sites.google.com/ledgercomstarts.com/ledgercomstarts/
            https://sites.google.com/view/venmol0gin/
            https://sites.google.com/view/walmartgiftcardbalancecheckk/
            https://sites.google.com/view/url-amazon-com-redeem/
            https://sites.google.com/view/vanillagiftcardbalancee/
            https://sites.google.com/vanillaegiftcardbalance.com/vanillagiftcardbalance/
            https://sites.google.com/vanillaegiftcardbalance.com/vanillaegiftcardbalance/
            https://sites.google.com/vanillaegiftcardbalance.com/vanillagiftcardbalancecheck/
            https://sites.google.com/vanillaegiftcardbalance.com/vanillagiftcardbalances/
            https://amazoncomcode.onepage.website/
            https://sites.google.com/ledgercomstarts.com/ledgercomstart/
            https://sites.google.com/view/dunkindonutsgiftcardbalances/
            https://sites.google.com/view/amazoncomredeemgift/
            https://sites.google.com/view/url-amazoncom-mytv/
            https://sites.google.com/view/amazon-redeem-canada/
            https://sites.google.com/view/amazoncomredeemuk/
            https://sites.google.com/mytargetgiftcardbalance.com/targetcomcheckbalance/
            https://sites.google.com/mytargetgiftcardbalance.com/targetgiftcardbalance/
            https://sites.google.com/view/sephoragiftcardbalance/
            https://sites.google.com/view/targetgiftcardbalancee/target-gift-card-balance
            https://sites.google.com/view/targetcomcheckbalance/
            https://sites.google.com/gifrcard-balance.com/ebaygiftcardbalance/
            https://sites.google.com/targetredcardslogin.com/targetredcardlogin/
            https://sites.google.com/view/itunes-gift-card-balance/
            https://sites.google.com/view/ebay-gift-card-balance/
            https://sites.google.com/view/fandangogiftcardbalance/
            https://sites.google.com/gifrcard-balance.com/bestbuygiftcardbalance/
            https://sites.google.com/view/nikegiftcardbalance/

            1 Reply Last reply Reply Quote 0
            • First post
              Last post