Svend
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
7 additions and
3 deletions
-
packages/effects/request/src/request-client/modules/downloader.ts
-
packages/effects/request/src/request-client/types.ts
|
|
@ -1,6 +1,7 @@ |
|
|
import type { AxiosRequestConfig, AxiosResponse } from 'axios'; |
|
|
import type { AxiosRequestConfig } from 'axios'; |
|
|
|
|
|
|
|
|
import type { RequestClient } from '../request-client'; |
|
|
import type { RequestClient } from '../request-client'; |
|
|
|
|
|
import type { RequestResponse } from '../types'; |
|
|
|
|
|
|
|
|
class FileDownloader { |
|
|
class FileDownloader { |
|
|
private client: RequestClient; |
|
|
private client: RequestClient; |
|
|
@ -12,13 +13,13 @@ class FileDownloader { |
|
|
public async download( |
|
|
public async download( |
|
|
url: string, |
|
|
url: string, |
|
|
config?: AxiosRequestConfig, |
|
|
config?: AxiosRequestConfig, |
|
|
): Promise<AxiosResponse<Blob>> { |
|
|
): Promise<RequestResponse<Blob>> { |
|
|
const finalConfig: AxiosRequestConfig = { |
|
|
const finalConfig: AxiosRequestConfig = { |
|
|
...config, |
|
|
...config, |
|
|
responseType: 'blob', |
|
|
responseType: 'blob', |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const response = await this.client.get<AxiosResponse<Blob>>( |
|
|
const response = await this.client.get<RequestResponse<Blob>>( |
|
|
url, |
|
|
url, |
|
|
finalConfig, |
|
|
finalConfig, |
|
|
); |
|
|
); |
|
|
|
|
|
@ -4,6 +4,8 @@ import type { |
|
|
InternalAxiosRequestConfig, |
|
|
InternalAxiosRequestConfig, |
|
|
} from 'axios'; |
|
|
} from 'axios'; |
|
|
|
|
|
|
|
|
|
|
|
type RequestResponse<T = any> = AxiosResponse<T>; |
|
|
|
|
|
|
|
|
type RequestContentType = |
|
|
type RequestContentType = |
|
|
| 'application/json;charset=utf-8' |
|
|
| 'application/json;charset=utf-8' |
|
|
| 'application/octet-stream;charset=utf-8' |
|
|
| 'application/octet-stream;charset=utf-8' |
|
|
@ -46,5 +48,6 @@ export type { |
|
|
RequestClientOptions, |
|
|
RequestClientOptions, |
|
|
RequestContentType, |
|
|
RequestContentType, |
|
|
RequestInterceptorConfig, |
|
|
RequestInterceptorConfig, |
|
|
|
|
|
RequestResponse, |
|
|
ResponseInterceptorConfig, |
|
|
ResponseInterceptorConfig, |
|
|
}; |
|
|
}; |
|
|
|