question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hey,

is there a way to get the length of the stream? (size of the uploaded file)

😄

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
dizlexikcommented, Dec 21, 2017

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.

1reaction
mike-marcaccicommented, Jul 26, 2018

@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 its bytesWritten 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found