is it possible to use http service? #950

Open
opened 2017-12-26 16:03:49 +00:00 by Viktor-Bredihin · 10 comments
Viktor-Bredihin commented 2017-12-26 16:03:49 +00:00 (Migrated from github.com)

I need upload requests to go through interceptors

I need upload requests to go through interceptors
Davinci-Leonardo commented 2018-01-15 14:35:54 +00:00 (Migrated from github.com)

Do we have any update on this issue? Because i also need to know to configure it, but i can't figure out.....

Do we have any update on this issue? Because i also need to know to configure it, but i can't figure out.....
Viktor-Bredihin commented 2018-01-15 15:11:34 +00:00 (Migrated from github.com)

@Asargiotakis
it's not possible, and no one cares. Look this lib instead https://www.primefaces.org/primeng/#/fileupload

@Asargiotakis it's not possible, and no one cares. Look this lib instead https://www.primefaces.org/primeng/#/fileupload
Davinci-Leonardo commented 2018-01-15 19:58:07 +00:00 (Migrated from github.com)

@Viktor-Bredihin do you know how this module uploads a file?? i try to find the way he does the uploading but i cant understand.... Is it using http or httpClient to do the POST?
Because i think http (angular/http) is not supported by HttpClient(angular/common/http) interceptor

@Viktor-Bredihin do you know how this module uploads a file?? i try to find the way he does the uploading but i cant understand.... Is it using http or httpClient to do the POST? Because i think http (angular/http) is not supported by HttpClient(angular/common/http) interceptor
Nightbr commented 2018-02-05 17:18:45 +00:00 (Migrated from github.com)

this module has its proper upload process using the Javascript api xhr in order to optimise and upload your file. If you need to pass an Authorization token, you can use the parameter authToken on ng2FileDrop.

But it could be great to handle interceptor register in Angular5.

this module has its proper upload process using the Javascript api xhr in order to optimise and upload your file. If you need to pass an Authorization token, you can use the parameter authToken on ng2FileDrop. But it could be great to handle interceptor register in Angular5.
mitschmidt commented 2018-03-29 12:28:08 +00:00 (Migrated from github.com)

Same here - using HTTP interceptors seems like a huge advantage in angular 2/5, and this forced devs to implement some functionality redundantly (like token interceptor).

Would be really useful adaption to have this with the existing nice module.

Same here - using HTTP interceptors seems like a huge advantage in angular 2/5, and this forced devs to implement some functionality redundantly (like token interceptor). Would be really useful adaption to have this with the existing nice module.
harisbarki commented 2018-07-07 01:14:36 +00:00 (Migrated from github.com)

You can use JWT token like this. It will be attached in headers as Authorization.
this.uploader = new FileUploader({url: URL, queueLimit: 10, authToken: this.authService.getToken()});
screen shot 2018-07-06 at 10 43 26 pm

You can use JWT token like this. It will be attached in headers as Authorization. `this.uploader = new FileUploader({url: URL, queueLimit: 10, authToken: this.authService.getToken()});` <img width="506" alt="screen shot 2018-07-06 at 10 43 26 pm" src="https://user-images.githubusercontent.com/10603745/42405304-20e30ce8-816e-11e8-9403-69673d8fbe28.png">
WindSaber commented 2018-07-19 18:01:04 +00:00 (Migrated from github.com)

There is another simple way to add headers for example instead of using interceptors:

Look at next example adding Bearer Authorization for jwt

uploader: FileUploader = new FileUploader({
    url: '<my_url>',
    authToken: `Bearer ${my_token}`,
    additionalParameter: {
      more_data: "foo"
    }
  });
There is another simple way to add headers for example instead of using interceptors: Look at next example adding Bearer Authorization for jwt ``` uploader: FileUploader = new FileUploader({ url: '<my_url>', authToken: `Bearer ${my_token}`, additionalParameter: { more_data: "foo" } }); ```
sumpton commented 2019-03-04 15:43:13 +00:00 (Migrated from github.com)

We use refresh tokens and HTTP interceptor to get new JWT tokens. Sort of the point of Angular and HttpClient. It works perfectly and transparently on all our routes except upload. The intercepter queues requests for the brief time to refresh, so just adding a token to a call and bypass the interceptor will fail from time to time as the JWT expires.

We use refresh tokens and HTTP interceptor to get new JWT tokens. Sort of the point of Angular and HttpClient. It works perfectly and transparently on all our routes except upload. The intercepter queues requests for the brief time to refresh, so just adding a token to a call and bypass the interceptor will fail from time to time as the JWT expires.
omardoma commented 2019-07-09 02:44:42 +00:00 (Migrated from github.com)

Hello Guys, I have written a new file uploads library that solves this issue, have a look at it: ng-uploader

Hello Guys, I have written a new file uploads library that solves this issue, have a look at it: [ng-uploader](https://github.com/trendster-io/ng-uploader)
dvyue commented 2019-12-05 10:26:31 +00:00 (Migrated from github.com)

@harisbarki I am also using this approach, but couldn't make it work with my authToken coming as an Observable. Can you share how you're doing it? Thanks!

@harisbarki I am also using this approach, but couldn't make it work with my authToken coming as an Observable. Can you share how you're doing it? Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#950