Skip to content

Commit ff4b57f

Browse files
authored
Merge pull request #34 from yllieth/add-bucket_info
Add bucket info
2 parents d1643de + 6070749 commit ff4b57f

File tree

8 files changed

+38
-20
lines changed

8 files changed

+38
-20
lines changed

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "predicsis_ml_sdk-javascript",
3-
"version": "0.7.2",
3+
"version": "0.7.3",
44
"authors": [
55
"Yllieth <[email protected]>",
66
"Dehau"
@@ -37,4 +37,4 @@
3737
"devDependencies": {
3838
"angular-mocks": "~1.3.15"
3939
}
40-
}
40+
}

dist/predicsis-jsSDK.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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];

dist/predicsis-jsSDK.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/predicsis-jsSDK.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/helper/uploadHelper.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ angular
115115
}
116116
},
117117
function uploadChunks(ctx) {
118-
uploadId = ctx.id;
119-
uploadPath = ctx.path;
118+
var uploadId = ctx.id;
119+
var uploadPath = ctx.path;
120120
var result = collection
121121
.map(
122122
chunks(file, { chunkSize: chunkSize, fileOffset: fileOffset }),
@@ -136,13 +136,13 @@ angular
136136
result.events.on('end', function() { fileOffset += chunkSize;});
137137
result.events.on('end', function(ctx) { delete chunksCancel[ctx.index]; });
138138
return result.all()
139-
.then(function() { return { uploadId: uploadId, uploadPath: uploadPath }; });
139+
.then(function() { return { uploadId: uploadId, uploadPath: uploadPath, container: container }; });
140140
},
141141
function completeUpload(ctx) {
142142
return tasks.retry({
143143
task: function() {
144144
return Uploads.complete(ctx.uploadId, ctx.uploadPath)
145-
.then(function() { return { uploadId: ctx.uploadId, uploadPath: ctx.uploadPath, type: ctx.type }; });
145+
.then(function() { return { uploadId: ctx.uploadId, uploadPath: ctx.uploadPath, type: ctx.type, container: ctx.container }; });
146146
},
147147
isRetryable: function(err) {
148148
// AWS S3 could return 400 after network issues => retyable
@@ -253,7 +253,7 @@ angular
253253
});
254254
uploadRes.then(function(ctx) {
255255
delete concurrentUploads[uploadId];
256-
$rootScope.$broadcast('jsSDK.upload.uploaded', { id: uploadId, path: ctx.uploadPath, fileName: file.name, type: ctx.type });
256+
$rootScope.$broadcast('jsSDK.upload.uploaded', { id: uploadId, path: ctx.uploadPath, fileName: file.name, type: ctx.type, container: ctx.container });
257257
});
258258
uploadRes.catch(function(err) {
259259
//delete concurrentUploads[uploadId];

lib/model/Datasets.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,18 +248,21 @@ angular
248248
* @param {String} fileName used to create the source and the dataset
249249
* @param {String} destFolder AWS key where the dataset has been uploaded
250250
* @param {String} pathName name of the key used to provide destFolder ('key' for S3, 'object' for swift)
251+
* @param {String} container name of the container or bucket used for uploading file
251252
* @return {Promise} Newly created dataset
252253
*/
253-
this.createFromUpload = function(fileName, destFolder, type) {
254+
this.createFromUpload = function(fileName, destFolder, type, container) {
254255
type = type || 's3';
255256

256257
var Sources = $injector.get('Sources');
257258
var source = { name: fileName, data_file: { filename: fileName } };
258259
var dataStore = { type: type };
259260
if (type === 's3') {
260261
dataStore.key = destFolder;
262+
dataStore.bucket = container;
261263
} else if (type === 'swift') {
262264
dataStore.object = destFolder;
265+
dataStore.container = container;
263266
} else {
264267
throw 'Invalid source dataStore type : ' + type;
265268
}

lib/model/Uploads.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ angular
5757
* @return {Promise} New upload
5858
*/
5959
this.initiate = function() {
60-
return uploads().post({});
60+
return uploads().post({})
61+
.then(function(result) {
62+
if (result.type === 's3') {
63+
result.container = result.bucket;
64+
}
65+
return result;
66+
});
6167
};
6268

6369
/**

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "predicsis_ml_sdk-javascript",
3-
"version": "0.7.2",
3+
"version": "0.7.3",
44
"description": "Javascript SDK for PredicSis ML API",
55
"main": "index.js",
66
"scripts": {
@@ -42,4 +42,4 @@
4242
"load-grunt-tasks": "^3.1.0",
4343
"phantomjs": "^1.9.16"
4444
}
45-
}
45+
}

0 commit comments

Comments
 (0)