mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Pass onUploadProgress function through to the axios request (#6007)
The AxiosRequest config allows for an onUploadProgress function to be passed in. This is useful, if we want to give users some kind of feedback about the progress of a potential file transfer. Currently, the sdk is only supporting this via direct access to the transport method. Co-authored-by: Mirko Nitschke <mnitscke93@gmail.com>
This commit is contained in:
@@ -48,6 +48,7 @@ export class AxiosTransport implements ITransport {
|
||||
options.sendAuthorizationHeaders = options.sendAuthorizationHeaders ?? true;
|
||||
options.refreshTokenIfNeeded = options.refreshTokenIfNeeded ?? true;
|
||||
options.headers = options.headers ?? {};
|
||||
options.onUploadProgress = options.onUploadProgress ?? undefined;
|
||||
|
||||
if (options.refreshTokenIfNeeded) {
|
||||
await this._refresh();
|
||||
@@ -59,6 +60,7 @@ export class AxiosTransport implements ITransport {
|
||||
data: data,
|
||||
params: options.params,
|
||||
headers: options.headers,
|
||||
onUploadProgress: options.onUploadProgress,
|
||||
};
|
||||
|
||||
const token = this._storage.auth_token;
|
||||
|
||||
@@ -24,6 +24,7 @@ export type TransportOptions = {
|
||||
headers?: any;
|
||||
refreshTokenIfNeeded?: boolean;
|
||||
sendAuthorizationHeaders?: boolean;
|
||||
onUploadProgress?: ((progressEvent: any) => void) | undefined;
|
||||
};
|
||||
|
||||
export interface ITransport {
|
||||
|
||||
Reference in New Issue
Block a user