Closed rteslaru closed 8 years ago
I found that I could get the file size via validateRequest: function(req)
-- the size is in req.headers['content-length']
. It's definitely not the same thing, of course, but it's a quick and dirty workaround.
However, as I just mentioned in #155, validateRequest
does not work either: return false
allows uploads anyway, and return true
complains about TypeError: first argument must be a string or Buffer
.
Using upload-server 1.3.2 on Meteor 1.2.1
Hi,
Do you have any update on this? It would be great if you could let me know if this is already fixed, and if the fixed version is released as a new package on atmosphere. Let me know if I can help with anything!
Thanks!
@rteslaru, sorry for a very late response. There was an error in the package which is now fixed. I have also updated the documentation that states that failed validation returns a description of validation error and passed validation returns null. Asa failsafe, I have added the possibility to return null with the default text of "validationFailed".
Concerning the file size. You were right! I amd calling validation BEFORE the file has uploaded to the server, thus server did not know about the file size. As a result I have moved the validation to state when file is uploaded to the server.
This way, you can use Validate request to cancel any upload that is not valid BEFORE it starts uploading. And you can use validateFile to validate the integrity of uploaded file AFTER it was uploaded on the server.
Hi,
Thanks for a great package, this is proving to be really useful! I just ran into a bit of an issue, however.
I'm trying to use the
validateFile: function(fileInfo)
andreturn true
iffileInfo.size < maxSize
-- however, size is always set to 0.This is the object that gets passed to the callback:
Do you have any suggestion on where to start looking for a fix?
Thanks!