@@ -471,18 +471,21 @@ angular
471471 * @param {String } fileName used to create the source and the dataset
472472 * @param {String } destFolder AWS key where the dataset has been uploaded
473473 * @param {String } pathName name of the key used to provide destFolder ('key' for S3, 'object' for swift)
474+ * @param {String } container name of the container or bucket used for uploading file
474475 * @return {Promise } Newly created dataset
475476 */
476- this . createFromUpload = function ( fileName , destFolder , type ) {
477+ this . createFromUpload = function ( fileName , destFolder , type , container ) {
477478 type = type || 's3' ;
478479
479480 var Sources = $injector . get ( 'Sources' ) ;
480481 var source = { name : fileName , data_file : { filename : fileName } } ;
481482 var dataStore = { type : type } ;
482483 if ( type === 's3' ) {
483484 dataStore . key = destFolder ;
485+ dataStore . bucket = container ;
484486 } else if ( type === 'swift' ) {
485487 dataStore . object = destFolder ;
488+ dataStore . container = container ;
486489 } else {
487490 throw 'Invalid source dataStore type : ' + type ;
488491 }
@@ -3056,7 +3059,13 @@ angular
30563059 * @return {Promise } New upload
30573060 */
30583061 this . initiate = function ( ) {
3059- return uploads ( ) . post ( { } ) ;
3062+ return uploads ( ) . post ( { } )
3063+ . then ( function ( result ) {
3064+ if ( result . type === 's3' ) {
3065+ result . container = result . bucket ;
3066+ }
3067+ return result ;
3068+ } ) ;
30603069 } ;
30613070
30623071 /**
@@ -3542,8 +3551,8 @@ angular
35423551 }
35433552 } ,
35443553 function uploadChunks ( ctx ) {
3545- uploadId = ctx . id ;
3546- uploadPath = ctx . path ;
3554+ var uploadId = ctx . id ;
3555+ var uploadPath = ctx . path ;
35473556 var result = collection
35483557 . map (
35493558 chunks ( file , { chunkSize : chunkSize , fileOffset : fileOffset } ) ,
@@ -3563,13 +3572,13 @@ angular
35633572 result . events . on ( 'end' , function ( ) { fileOffset += chunkSize ; } ) ;
35643573 result . events . on ( 'end' , function ( ctx ) { delete chunksCancel [ ctx . index ] ; } ) ;
35653574 return result . all ( )
3566- . then ( function ( ) { return { uploadId : uploadId , uploadPath : uploadPath } ; } ) ;
3575+ . then ( function ( ) { return { uploadId : uploadId , uploadPath : uploadPath , container : container } ; } ) ;
35673576 } ,
35683577 function completeUpload ( ctx ) {
35693578 return tasks . retry ( {
35703579 task : function ( ) {
35713580 return Uploads . complete ( ctx . uploadId , ctx . uploadPath )
3572- . then ( function ( ) { return { uploadId : ctx . uploadId , uploadPath : ctx . uploadPath , type : ctx . type } ; } ) ;
3581+ . then ( function ( ) { return { uploadId : ctx . uploadId , uploadPath : ctx . uploadPath , type : ctx . type , container : ctx . container } ; } ) ;
35733582 } ,
35743583 isRetryable : function ( err ) {
35753584 // AWS S3 could return 400 after network issues => retyable
@@ -3680,7 +3689,7 @@ angular
36803689 } ) ;
36813690 uploadRes . then ( function ( ctx ) {
36823691 delete concurrentUploads [ uploadId ] ;
3683- $rootScope . $broadcast ( 'jsSDK.upload.uploaded' , { id : uploadId , path : ctx . uploadPath , fileName : file . name , type : ctx . type } ) ;
3692+ $rootScope . $broadcast ( 'jsSDK.upload.uploaded' , { id : uploadId , path : ctx . uploadPath , fileName : file . name , type : ctx . type , container : ctx . container } ) ;
36843693 } ) ;
36853694 uploadRes . catch ( function ( err ) {
36863695 //delete concurrentUploads[uploadId];
0 commit comments