-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
55 lines (42 loc) · 1.3 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
Test for the objects-store-stub
*/
var path = require('path')
// read the information from the VCAP services of your Bluemix application/service using Object Store
var bluemixObjectStore = {
"auth_url": "https://identity.open.softlayer.com",
"project": "...",
"projectId": "...",
"region": "dallas",
"userId": "...",
"username": "...",
"password": "...",
"domainId": "...",
"domainName": "..."
};
downloadComplete = function( localFile, error) {
if ( error)
{
console.log( "Download error: " + error.failCode);
return;
}
console.log( "Download complete: " + localFile);
}
/*
* Download the result
*/
uploadComplete = function(objectStore, container, remoteFile, error) {
if ( error)
{
console.log( "Upload error: " + error.failCode);
return;
}
console.log( "Upload complete: " + remoteFile);
var localFile = "./test/download/" + remoteFile;
objectStore.retrieveFile( container, remoteFile, localFile, downloadComplete);
}
// upload and download 2 files
var ObjectStoreStub = require('./store/object-store-stub');
var objectStore = new ObjectStoreStub( bluemixObjectStore);
objectStore.storeFile( "test", "./test/upload/image.jpg", uploadComplete);
objectStore.storeFile( "test", "./test/upload/text.txt", uploadComplete);