feat: add abort upload and upload progress handler
This commit is contained in:
parent
f899e909f0
commit
4bf0e22bc2
1 changed files with 8 additions and 3 deletions
|
|
@ -356,15 +356,20 @@ export function manageFile<T extends string>(
|
||||||
parentId: string;
|
parentId: string;
|
||||||
fileId: string;
|
fileId: string;
|
||||||
file: File;
|
file: File;
|
||||||
|
onUploadProgress?: (e: AxiosProgressEvent) => void;
|
||||||
|
abortController?: AbortController;
|
||||||
}) => {
|
}) => {
|
||||||
const res = await api.put(
|
const res = await api.put(
|
||||||
`/${base}/${opts.parentId}/file-${opts.group}/${opts.fileId}`,
|
`/${base}/${opts.parentId}/file-${opts.group}/${opts.fileId}`,
|
||||||
opts.file,
|
opts.file,
|
||||||
{
|
{
|
||||||
headers: { 'Content-Type': opts.file.type },
|
headers: { 'Content-Type': opts.file.type },
|
||||||
onUploadProgress: option?.onUploadProgress
|
onUploadProgress: opts.onUploadProgress
|
||||||
|
? opts.onUploadProgress
|
||||||
|
: option?.onUploadProgress
|
||||||
? option.onUploadProgress
|
? option.onUploadProgress
|
||||||
: (e) => console.log(e),
|
: (e) => console.log(e),
|
||||||
|
signal: opts.abortController?.signal,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (res.status < 400) return true;
|
if (res.status < 400) return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue