@@ -21,13 +21,13 @@ import useSaveData from '../useSaveData/useSaveData';
2121import { getItemProgress } from './utils' ;
2222import { RegularFile , FileVariables , FileStatus } from './types' ;
2323
24- interface UseUploadQueueResponse {
25- addFiles : ( item : RegularFile [ ] ) => void ;
24+ interface UseRegularUploadResponse {
25+ addFiles : ( items : RegularFile [ ] , overwrite ?: boolean ) => void ;
2626 cancelFile : ( uuid : RegularFile [ 'uuid' ] ) => void ;
2727 isLoading : boolean ;
2828}
2929
30- interface UploadQueueOptions {
30+ interface UseRegularUploadProps {
3131 concurrentProcess ?: number ;
3232 updateFileVariables : ( item : RegularFile [ 'uuid' ] , variables : FileVariables ) => void ;
3333 onComplete : ( ) => void ;
@@ -37,15 +37,14 @@ const useRegularUpload = ({
3737 concurrentProcess = DEFAULT_CONCURRENT_MAX_CONNECTIONS ,
3838 updateFileVariables,
3939 onComplete
40- } : UploadQueueOptions ) : UseUploadQueueResponse => {
40+ } : UseRegularUploadProps ) : UseRegularUploadResponse => {
4141 const { save } = useSaveData ( UPLOAD_FILE_URL ) ;
4242
4343 const processRegularFile = async ( item : RegularFile ) => {
4444 updateFileVariables ( item . uuid , { status : FileStatus . Uploading } ) ;
4545
4646 const payload = new FormData ( ) ;
4747 payload . append ( 'file' , item . file ) ;
48- payload . append ( 'destination_path' , item . filePath ) ;
4948
5049 return save ( payload , {
5150 onSuccess : ( ) => {
@@ -55,6 +54,9 @@ const useRegularUpload = ({
5554 updateFileVariables ( item . uuid , { status : FileStatus . Failed , error } ) ;
5655 } ,
5756 postOptions : {
57+ params : {
58+ destination_path : item . filePath
59+ } ,
5860 onUploadProgress : progress => {
5961 const itemProgress = getItemProgress ( progress ) ;
6062 updateFileVariables ( item . uuid , { progress : itemProgress } ) ;
0 commit comments