@@ -24,7 +24,7 @@ export interface DropZoneProps {
24
24
// chunking
25
25
chunking ?: string ,
26
26
// chunkSize
27
- chunkSize ?: number ,
27
+ chunkSize ?: string ,
28
28
// label
29
29
label ?: string ,
30
30
// addRemoveLinks
@@ -71,7 +71,7 @@ export const DropZone = React.forwardRef<HTMLFormElement, DropZoneProps>(
71
71
autoProcessQueue = true ,
72
72
hiddenLabel = false ,
73
73
chunking = "0" ,
74
- chunkSize = 2000000 ,
74
+ chunkSize = " 2000000" ,
75
75
dropzoneParams = { }
76
76
} ,
77
77
ref
@@ -88,7 +88,7 @@ export const DropZone = React.forwardRef<HTMLFormElement, DropZoneProps>(
88
88
maxFiles : max_files ,
89
89
maxFilesize : max_file_size ,
90
90
chunking : chunking == "1" ?? false ,
91
- chunkSize,
91
+ chunkSize : chunkSize != "" ? Number . parseInt ( chunkSize ) : 2000000 ,
92
92
retryChunks : true ,
93
93
url : url ,
94
94
params : { ...dropzoneParams }
@@ -169,7 +169,31 @@ export const DropZone = React.forwardRef<HTMLFormElement, DropZoneProps>(
169
169
( dropZone as Dropzone ) . on ( "error" , ( ) => {
170
170
setIsInfoHidden ( true ) ;
171
171
setIsHidden ( true ) ;
172
- } ) ;
172
+ } ) &&
173
+ ( dropZone as Dropzone ) . on ( "sending" , ( file : any , xhr , formData ) => {
174
+
175
+ console . log ( file , xhr , formData ) ;
176
+
177
+ if ( dropZoneParameter . chunking ) {
178
+ formData . append ( 'dzuuid' , file . upload ?. uuid ) ;
179
+ formData . append ( 'dztotalchunkcount' , file . upload ?. totalChunkCount ) ;
180
+
181
+ let index = 1 ;
182
+ // @ts -nocheck
183
+ if ( file . upload ?. chunks )
184
+ {
185
+ index = file . upload . chunks [ file . upload . chunks . length - 1 ] . index
186
+ }
187
+
188
+ formData . append ( 'dzchunkindex' , index . toString ( ) ) ;
189
+ formData . append ( 'dztotalfilesize' , file . size ) ;
190
+ formData . append ( 'dzchunksize' , dropZoneParameter . chunkSize . toString ( ) ) ;
191
+ }
192
+ } ) &&
193
+ ( dropZone as Dropzone ) . on ( "chunksUploaded" , ( file , done ) => {
194
+ console . log ( file ) ;
195
+ done ( ) ;
196
+ } ) ;
173
197
174
198
// Initialization of DropZone
175
199
useEffect ( ( ) => {
0 commit comments