Allow for streaming uploads #223

Open
opened 2016-05-25 15:32:01 +00:00 by tdonohue · 3 comments
tdonohue commented 2016-05-25 15:32:01 +00:00 (Migrated from github.com)

Related to #121 , but not specific to Amazon S3.

Some APIs (Amazon S3 is just one example) expect streaming uploads rather than multipart uploads. This may be the case in REST APIs which expect a file to simply be streamed instead of parsing a form.

Currently, ng2-file-upload only supports multipart form uploads. If you are using an API that expects a streamed file, you will end up with a corrupted file on the server, as the binary content includes multipart form headers. For example, after uploading an image, on the server the raw image data will look something like this (and the image will be seen as corrupted):

------WebKitFormBoundarywMGsynmUCDADoKSG
Content-Disposition: form-data; name="file"; filename="my-image.png"
Content-Type: image/png
[actual-binary-image-data]
------WebKitFormBoundarywMGsynmUCDADoKSG--

The same is true for all file types. The form headers will end up inserted into the raw data of the file if the server-side API is expecting the file data to be streamed.

This same issue was recently resolved in angular-file-upload via this PR: https://github.com/nervgh/angular-file-upload/pull/602

A similar solution would likely work for ng2-file-upload.

Related to #121 , but not specific to Amazon S3. Some APIs (Amazon S3 is just one example) expect streaming uploads rather than multipart uploads. This may be the case in REST APIs which expect a file to simply be streamed instead of parsing a form. Currently, `ng2-file-upload` only supports multipart form uploads. If you are using an API that expects a streamed file, you will end up with a corrupted file on the server, as the binary content includes multipart form headers. For example, after uploading an image, on the server the raw image data will look something like this (and the image will be seen as corrupted): ``` ------WebKitFormBoundarywMGsynmUCDADoKSG Content-Disposition: form-data; name="file"; filename="my-image.png" Content-Type: image/png [actual-binary-image-data] ------WebKitFormBoundarywMGsynmUCDADoKSG-- ``` The same is true for all file types. The form headers will end up inserted into the raw data of the file if the server-side API is expecting the file data to be streamed. This same issue was recently resolved in `angular-file-upload` via this PR: https://github.com/nervgh/angular-file-upload/pull/602 A similar solution would likely work for `ng2-file-upload`.
junyun0516 commented 2016-06-16 06:43:23 +00:00 (Migrated from github.com)

Still not resolved this issue?

Still not resolved this issue?
tdonohue commented 2016-06-21 13:52:22 +00:00 (Migrated from github.com)

Note: this issue has a proposed fix in #224, which is still under review.

Note: this issue has a proposed fix in #224, which is still under review.
tdonohue commented 2016-06-23 16:14:38 +00:00 (Migrated from github.com)

This issue can be closed, as #224 was merged.

This issue can be closed, as #224 was merged.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#223