File size
See original GitHub issueHey,
is there a way to get the length
of the stream? (size of the uploaded file)
😄
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
File size - Wikipedia
File size is a measure of how much data a computer file contains or, alternately, how much storage it consumes. Typically, file size...
Read more >What Is The File Size? - Metadata2Go.com
The size of a file is the amount of space it takes up on your hard drive. The File Size is measured in...
Read more >File Size Calculator - File Size Explained - MindGems
File size calculator will convert file sizes to any units of measure - bits, bytes, kilobytes, megabytes, gigabytes, terabytes, or petabytes.
Read more >File Sizes and Transfer Speeds - 2BrightSparks
File sizes are measured in Bytes (B), Kilobytes (KB), Megabytes (MB), Gigabytes (GB), Terabytes (TB) and so on. The file sizes can be...
Read more >File sizes | AP CSP (article) | Khan Academy
File sizes are always measured in bytes. A byte is a sequence of 8 bits (and remember, a bit is the smallest piece...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 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
finish
event and use itsbytesWritten
property to get size. I don’t think we want to document the capacitor property as parts of our public API just yet, so you would need to more strictly pin your version if you chose to use that strategy, but it would let you do what you want very efficiently.