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

feat(http): add support for blob as a response type #10190

Merged
merged 2 commits into from Jul 21, 2016

Conversation

cassand
Copy link
Contributor

@cassand cassand commented Jul 20, 2016

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x")

[ ] Bugfix
[ x ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?
There is no way to receive a response as a blob.

What is the new behavior?
Allow to set the attribute responseType of the request, through the enum ResponseContentType.

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[ x ] No

Other information:

In order to add appropriate tests for this feature I have to introduce some change into the MockBrowserXHR, (which will also allow to test arraybuffer, json and text as a responseType), therefore I will add them in a future commit.

Allow to set the attribute responseType of the request, through the enum ResponseContentType.
@zoechi
Copy link
Contributor

zoechi commented Jul 20, 2016

related to angular/http#75 ?

@@ -179,14 +179,15 @@ export declare class Response extends Body {

/** @experimental */
export declare enum ResponseContentType {
ArrayBuffer = 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to explicitly assign value here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generated by the command gulp public-api:update, if the values are not explicitly assigned, then any call to gulp public-api:update will put back the values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right. didn't notice it was a .d.ts file before

@vicb
Copy link
Contributor

vicb commented Jul 20, 2016

Please add tests. Thanks

@vicb vicb added feature Issue that requests a new feature comp: http labels Jul 20, 2016
cassand added a commit to cassand/angular that referenced this pull request Jul 20, 2016
Expose a spy to test change on responseType, which allow to test responseType in XHRBackend on PR angular#7260 and PR angular#10190
@vicb vicb added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jul 20, 2016
@cassand
Copy link
Contributor Author

cassand commented Jul 20, 2016

@vicb Sure, but I will need this PR #10194 to be merged in order to add appropriate tests (without this the attribute responseType can't be tested and the rest is already covered with tests in #7260 ).

@vicb
Copy link
Contributor

vicb commented Jul 20, 2016

@cassand please merge both the PRs and add tests. Thanks

@vicb vicb added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Jul 21, 2016
Test if the attribute responseType of the request is correctly set when the corresponding response content type is passed.
@cassand
Copy link
Contributor Author

cassand commented Jul 21, 2016

Both requests are merged and the feature is tested.

@vicb vicb added pr_state: LGTM and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 21, 2016
@vicb vicb merged commit 76b8a49 into angular:master Jul 21, 2016
hbkrunal pushed a commit to hbkrunal/angular that referenced this pull request Sep 15, 2016
@tomalex0
Copy link

tomalex0 commented Sep 28, 2016

I'm forced to ask here as i don't got any response from gitter.

Any example showcasing sending FormData as part of http,

Below code works fine for me but like to know if same supported in http

 var files = $event.target.files || $event.srcElement.files;
        var file = files[0];
        let formData = new FormData();
        formData.append("single_fileup", file);
        formData.append('key1', 'value1');
        formData.append('key2', 'value2');
       var req = new XMLHttpRequest();
       req.open("POST", "/api/fileupload");
       req.send(formData);
var multer  = require('multer');
var storage = multer.memoryStorage();
var upload = multer({ storage: storage });
  router.post('/api/fileupload', upload.single('single_fileup'), function(req, res, next){

});

How to make below code work?

 this.http.post('/api/fileupload', formData)
            .map(this.extractData)
            .catch(this.handleError);

I have posted same here also http://stackoverflow.com/questions/39731066/how-to-upload-filesmultipart-using-angularjs2

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews cla: yes feature Issue that requests a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants