ruby on rails - How to validate file size of file before upload? -
I am using carrier access to handle my file upload and now I want to add verification so that user 1 GB Can not upload file or similar.
For now I have done this like this:
class items & lt; ActiveRecord :: Base mount_uploader: Image, Image Uploader Valid: file_size def file_size Errors [: Image] & lt; & Lt; "Too big" if self.image.parametres [: shape]> gt; 100000 End End
The problem is that I feel that this verification works after the file has already been processed. I get stuck in a few minutes after uploading a large file of 30MB and then informs me that the file is too big. It appears that the file is uploaded to the cache and then the verification runs. This is not really acceptable.
Is there any other way to run validation? Thanks!
The easiest way would be to transfer the file before writing some JS file to validate the client side is.
Comments
Post a Comment