-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File size #30
Comments
To avoid trusting what the client says, and due to the nature of streaming uploads we can't tell how big the file is until it has finished streaming in. It is up to you to either meter the stream by piping it through a library, or you could simply inspect the file once it has finished streaming to wherever you are storing it. Keep in mind that there is a |
It actually would be nice to have access to the file size that the client reports even if it is possible for them to lie about it. In the vast majority of cases it will be accurate and it would be nice to use it in the maxFileSize validation to short-circuit the process and avoid needlessly pulling in maxFileSize bytes of data before erroring out. This would be desired behavior even if the client misreports the size, e.g. if they lie and say the file is bigger than it really is then we would still want to throw an error and now allow it. And if they lie and underreport then it will still error out once the uploaded bytes reaches maxFileSize. |
@jaydenseric @mike-marcacci with #81 now merged, we have the uploads into temp files...correct? So this should theoretically allow us to have the actual size for each upload. |
@loremaps the temp files are an implementation detail of the file streams provided to resolvers. The API is still a stream, so you still don't know how big the final file will be until the stream ends. |
@jaydenseric is correct that it’s just an implementation detail, and in the future we may do something like buffer to memory up to a certain size, then fall back to the file system. However, if we end up going with #92 as written (it’s still a WIP) you would have access to the writable stream (the capacitor property), and could listen for its |
Hey,
is there a way to get the
length
of the stream? (size of the uploaded file)😄
The text was updated successfully, but these errors were encountered: