vue-upload-multiple-image
vue-upload-multiple-image copied to clipboard
Feature: Max size in bytes per image
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)
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
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 😉
(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