NoelOConnell/quill-image-uploader

Return img src path with no delay

henpin opened this issue · 2 comments

I added the following code to my app

          imageUploader: {
            upload: async (file) => {
              if (!this.$utils.checkUploadFileSize(file)) { // If over 1MB
                this.$snackbar.show("can not upload file over 1MB");
                return "/img/no-image.png";
              }
              return await storage.articleImage.upload(file);
            },
          },

If file size is over 1MB, then I want the behavior as below

  1. insert <img src="/img/no-image.png">
  2. disappear image-loader inserted by quill-image-uploader

But the image-loader dosen't disappear (and it appears forever).
Because quill-image-uploader seems to need seconds delay before return path.

I want to return path with no delay.

upload method should return a promise.
Try:

          imageUploader: {
            upload: async (file) => {
                if (!this.$utils.checkUploadFileSize(file)) { // If over 1MB
                  this.$snackbar.show("can not upload file over 1MB");
                  return new Promise(resolve=>{
                    resolve("/img/no-image.png");
                  })
                }
              return await storage.articleImage.upload(file);
            },
          },

I added the following code to my app

          imageUploader: {
            upload: async (file) => {
              if (!this.$utils.checkUploadFileSize(file)) { // If over 1MB
                this.$snackbar.show("can not upload file over 1MB");
                return "/img/no-image.png";
              }
              return await storage.articleImage.upload(file);
            },
          },

If file size is over 1MB, then I want the behavior as below

  1. insert <img src="/img/no-image.png">
  2. disappear image-loader inserted by quill-image-uploader

But the image-loader dosen't disappear (and it appears forever). Because quill-image-uploader seems to need seconds delay before return path.

I want to return path with no delay.

I noticed that too, so I always introduce a delay until the promise is resolved.