Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Implement file.on('data' #72

Closed
retrohacker opened this issue Mar 21, 2017 · 4 comments
Closed

Implement file.on('data' #72

retrohacker opened this issue Mar 21, 2017 · 4 comments

Comments

@retrohacker
Copy link
Contributor

https://github.com/Storj/storj.js#fileondata-function-cbdata-

Will require a PR to core, currently planned but not implemented.

@rockydd
Copy link

rockydd commented Mar 22, 2017

The getFile() function will download the file in backend before it can generate the blob URL, right? Is this the only way to download file? I want to make Browser to make the download and track the progress. Now it's not possible, correct?

@nginnever
Copy link
Contributor

We currently have two methods for getting a file from farmers via the browser.

  1. As you mention you can use the File class to wait for the file to be decrypted and stored in memory before using the blob url.

  2. Use the low-level api to get a direct read stream of the decryption stream. https://github.com/Storj/storj.js#var-stream--storjdownloadfileid-bucketid

What we don't have is a standard way to track file upload/download progress. This requires a decision to be made on what constitutes progress since we have a few stages of streaming that we could listen to data events on.

@retrohacker
Copy link
Contributor Author

Yup, exactly what @nginnever said.

The challenge is that we are using a large data structure that handles most of the upload/download for us. We (currently) don't get access to the data coming over the wire -- i.e. when we receive bits, when those bits are validated as correct, when they are decrypted, etc.-- which means we can't really deliver a reliable metric for file.progress. Not to mention the underlying data structure often returns the entire file in one big 'data' event so progress would jump from 0 to 1 instantly anyways, which is the current behaviour.

The changes we will need to make for this to work are rather large, but planned. Once we get a reliable file.progress, we can implement something along the lines of file.speed (name TBD) which computes how much data is moving over the wire over a unit of time.

Right now this is a lower priority than supporting large files. The size of the file we can reasonable support in the browser without those changes is pretty small. Transfers often take <1 second, while the handling of the data -- decrypting and concatenating streams -- takes quite a bit longer. progress doesn't have as much meaning until we remove that bottleneck.

@retrohacker retrohacker changed the title Need to document file.on('data' not implemented Implement document file.on('data' Mar 22, 2017
@retrohacker retrohacker changed the title Implement document file.on('data' Implement file.on('data' Mar 22, 2017
@RichardLitt
Copy link
Contributor

👋 Hey! Thanks for this contribution. Apologies for the delay in responding!

We've decided to rearchitect Storj, so that we can scale better. You can read more about this decision here. This means that we are entirely focused on v3 at the moment, in the storj/storj repository. Our white paper for v3 is coming very, very soon - follow along on the blog and in our Rocketchat.

As this repository is part of the v2 network, we're no longer maintaining this repository. I am going to close this for now. If you have any questions, I encourage you to jump on Rocketchat and ask them there. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants