vue-upload-multiple-image icon indicating copy to clipboard operation
vue-upload-multiple-image copied to clipboard

Feature: Max size in bytes per image

Open arellano-gustavo opened this issue 5 years ago • 3 comments

Currently there is no way to limit the size of an image to be uploaded.

Also, there should be a max limit for the original size of an image to be uploaded; something like 1920x1024 or W:2048 H:1366 (this is just an example. the implementation can be any)

arellano-gustavo avatar Jul 02 '19 15:07 arellano-gustavo

HI, I think that you can create a pull request Add the maxSize prop and then in the createImage (file) You can check if (file.size > this.maxSize) this.$emit('upload-failed', 'Image size too big') Hope it helps

uriwald avatar Dec 04 '19 02:12 uriwald

Hi, Can I make this feature?

Actually, I've already made it, but it's a little different what you suggested 😭 Because I made it for my project... You can see it here!

I hope it's similar to what you wanted 😉

du-dung avatar Sep 16 '20 17:09 du-dung

(Sorry my bad english) Hi! A found another solution, not perfect, but for me solved it. In function uploadImageSuccess (where I put my component) I do a validation of the size. If the size don't ar on my limit, I clear the file and show a message. I hope that helps.

uploadImageSuccess(formData, index, fileList) { const img = fileList[0].path const buffer = Buffer.from(img.substring(img.indexOf(',') + 1))

  if (buffer.length / 1e6 > 1.5) { // 1.5MB
    this.$toasted.info('error message')
    fileList = []
  }

(...)

}

Extra: See the first answer - about the size of the image uploaded https://stackoverflow.com/questions/52903386/how-to-get-byte-length-of-a-base64-string-in-node-js

contatofabiofg avatar Sep 21 '22 16:09 contatofabiofg