Skip to content
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

Upload streams from the browser #118

Closed
paulrosenzweig opened this issue Jul 20, 2018 · 1 comment · Fixed by #126
Closed

Upload streams from the browser #118

paulrosenzweig opened this issue Jul 20, 2018 · 1 comment · Fixed by #126

Comments

@paulrosenzweig
Copy link
Contributor

In issue #59, @Acconut called out that it doesn't makes sense for tus-js-client to support the creation-defer-length extension until tusd supports it. However, since then, tusd has added support. Does it makes sense to add this feature now?

In terms of API level changes, I imagine the file argument to tus.Upload would be expanded to allow ReadableStream in addition to File and Blob.

If the server doesn't allow deferred length uploads, we could either error when passed a ReadableStream or just read the whole stream into a Blob and uploader it. I don't have strong feeling either way.

I'd be happy to take a stab at implementing this if y'all think support should be added.

@Acconut
Copy link
Member

Acconut commented Aug 1, 2018

Hi there, sorry for my late response. I personally have never used the new Streams API in browsers, so I am not sure what it actually can be used for. Furthermore, I am concerned about future changes of the Streams API. The MDN page (https://developer.mozilla.org/en-US/docs/Web/API/Streams_API#Browser_compatibility) says we should expect changes. Do you know what the status for the specification is?

That being said, I am not opposed to having support for them.

In terms of API level changes, I imagine the file argument to tus.Upload would be expanded to allow ReadableStream in addition to File and Blob.

I agree. That's similar to how ReadableStreams are accepted if tus-js-client is run inside Node.js. It might be helpful for you to look at how these are handled under the hood.

If the server doesn't allow deferred length uploads, we could either error when passed a ReadableStream or just read the whole stream into a Blob and uploader it. I don't have strong feeling either way.

In this case and that the user didn't specify the upload length in advance, the upload should not be read into a buffer. The user should do this explicitly to be aware of the required memory usage.

I'd be happy to take a stab at implementing this if y'all think support should be added.

Sure, please go ahead.

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

Successfully merging a pull request may close this issue.

2 participants