@@ -258,8 +258,12 @@ OC.FileUpload.prototype = {
258
258
&& this . getFile ( ) . size > this . uploader . fileUploadParam . maxChunkSize
259
259
) {
260
260
data . isChunked = true ;
261
+ var headers = ( OC . getCapabilities ( ) . dav . chunking === '2.0' ) ? {
262
+ 'X-Chunking-Destination' : this . getTargetDestination ( )
263
+ } : { } ;
264
+
261
265
chunkFolderPromise = this . uploader . davClient . createDirectory (
262
- 'uploads/' + OC . getCurrentUser ( ) . uid + '/' + this . getId ( )
266
+ 'uploads/' + OC . getCurrentUser ( ) . uid + '/' + this . getId ( ) , headers
263
267
) ;
264
268
// TODO: if fails, it means same id already existed, need to retry
265
269
} else {
@@ -298,17 +302,24 @@ OC.FileUpload.prototype = {
298
302
}
299
303
if ( size ) {
300
304
headers [ 'OC-Total-Length' ] = size ;
301
-
305
+ }
306
+ if ( OC . getCapabilities ( ) . dav . chunking === '2.0' ) {
307
+ headers [ 'X-Chunking-Destination' ] = this . getTargetDestination ( ) ;
302
308
}
303
309
304
310
return this . uploader . davClient . move (
305
311
'uploads/' + uid + '/' + this . getId ( ) + '/.file' ,
306
- 'files/' + uid + '/' + OC . joinPaths ( this . getFullPath ( ) , this . getFileName ( ) ) ,
312
+ this . getTargetDestination ( ) ,
307
313
true ,
308
314
headers
309
315
) ;
310
316
} ,
311
317
318
+ getTargetDestination : function ( ) {
319
+ var uid = OC . getCurrentUser ( ) . uid ;
320
+ return 'files/' + uid + '/' + OC . joinPaths ( this . getFullPath ( ) , this . getFileName ( ) )
321
+ } ,
322
+
312
323
_deleteChunkFolder : function ( ) {
313
324
// delete transfer directory for this upload
314
325
this . uploader . davClient . remove (
@@ -1133,7 +1144,6 @@ OC.Uploader.prototype = _.extend({
1133
1144
1134
1145
if ( options . maxChunkSize ) {
1135
1146
this . fileUploadParam . maxChunkSize = options . maxChunkSize ;
1136
- }
1137
1147
1138
1148
// initialize jquery fileupload (blueimp)
1139
1149
var fileupload = this . $uploadEl . fileupload ( this . fileUploadParam ) ;
@@ -1274,6 +1284,12 @@ OC.Uploader.prototype = _.extend({
1274
1284
var upload = self . getUpload ( data ) ;
1275
1285
var range = data . contentRange . split ( ' ' ) [ 1 ] ;
1276
1286
var chunkId = range . split ( '/' ) [ 0 ] . split ( '-' ) [ 0 ] ;
1287
+ if ( OC . getCapabilities ( ) . dav . chunking === '2.0' ) {
1288
+ // Calculate chunk index for usage with s3
1289
+ chunkId = Math . ceil ( ( data . chunkSize + Number ( chunkId ) ) / upload . uploader . fileUploadParam . maxChunkSize ) ;
1290
+ data . headers [ 'X-Chunking-Destination' ] = upload . getTargetDestination ( ) ;
1291
+ }
1292
+
1277
1293
data . url = OC . getRootPath ( ) +
1278
1294
'/remote.php/dav/uploads' +
1279
1295
'/' + OC . getCurrentUser ( ) . uid +
0 commit comments