Skip to content

Commit c739453

Browse files
committed
fix: add skipInterceptors
1 parent e0a81e7 commit c739453

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

projects/ngx-file-upload/src/lib/file-upload/file-upload.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class FileUploadService {
2121
private http: HttpClient,
2222
) { }
2323

24-
public uploadFile(file: File, prefix?: string): Observable<HttpResponse<void> | HttpUploadProgressEvent> {
24+
public uploadFile(file: File, prefix?: string, skipInterceptors?: boolean): Observable<HttpResponse<void> | HttpUploadProgressEvent> {
2525
// [
2626
// 'jpg', 'jpeg', 'png', 'gif',
2727
// 'webp', 'apng', 'tif', 'tiff',
@@ -35,6 +35,7 @@ export class FileUploadService {
3535
file.type,
3636
file?.name?.split('.')?.slice(-1)?.[0]?.toLowerCase() || 'jpg',
3737
prefix,
38+
skipInterceptors,
3839
).pipe(
3940
concatMap(
4041
({ data: uploadURLResult }) =>
@@ -43,7 +44,7 @@ export class FileUploadService {
4344
);
4445
}
4546

46-
private getUploadURL(mimeType: string, extension: string, prefix?: string,)
47+
private getUploadURL(mimeType: string, extension: string, prefix?: string, skipInterceptors?: boolean)
4748
: Observable<HandledHttpResponse<UploadURLResult>> {
4849
const params: { [key: string]: string | number } = {
4950
prefix: prefix!,
@@ -55,7 +56,7 @@ export class FileUploadService {
5556
s: `${Date.now()}${Math.floor(Math.random() * 1000)}`
5657
};
5758

58-
return this.http.get(this.config.getUploadLinkURL, { params, headers: {'skip-interceptors': "true"} })
59+
return this.http.get(this.config.getUploadLinkURL, { params, headers: !!skipInterceptors ? { 'skip-interceptors': "true" } : {} })
5960
.pipe(
6061
httpRetry(),
6162
catchError((err: HttpErrorResponse, caught: Observable<{ data: UploadURLResult, statusCode: number, message: any; }>) => {

0 commit comments

Comments
 (0)