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

WP-4242 CP-2600 Provide file upload guides/best practices #213

Open
evanweible-wf opened this issue Sep 6, 2016 · 1 comment
Open

WP-4242 CP-2600 Provide file upload guides/best practices #213

evanweible-wf opened this issue Sep 6, 2016 · 1 comment

Comments

@evanweible-wf
Copy link
Contributor

In particular, we should clarify that StreamedRequest is not the preferred solution for file uploads in the browser. Instead, the file should be sent directly or via a FormData/MultiPart request so that the browser can handle streaming the file for us.

The StreamedRequest isn't as useful in the browser due to it being implemented with XHR, which doesn't give us the ability to manually stream data. Because of this, the StreamedRequest implementation actually waits for the stream to complete and sends the entire payload as Uint8List (https://github.com/Workiva/w_transport/blob/master/lib/src/http/browser/request_mixin.dart#L112-L114)
Obviously we still want to be able to upload large payloads (like files) without loading it all into memory, but for security reasons, the browser has to do this for us. In this particular scenario, the way to do this is to send the file directly or in a FormData/MultiPart request so that the browser can handle the streaming for us. This works because these types of requests don't actually load the file into memory, they just have a pointer to the file location that the browser understands, whereas the StreamedRequest doesn't know this and actually reads the file.

@rm-astro-wf
Copy link
Contributor

It looks like you have not included any tickets in the title of this issue. Please create a ticket for this issue, or click here to have Rosie create one for you.

@evanweible-wf evanweible-wf changed the title Provide FileUpload guides/best practices Provide file upload guides/best practices Sep 6, 2016
@rm-astro-wf rm-astro-wf changed the title Provide file upload guides/best practices CP-2600 Provide file upload guides/best practices Sep 6, 2016
@rmconsole3-wf rmconsole3-wf changed the title CP-2600 Provide file upload guides/best practices WP-4242 CP-2600 Provide file upload guides/best practices May 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants