Permalink
Browse files

# blob copy working

  • Loading branch information...
1 parent 7d327d4 commit f0959ef0ef6444fb0a2c6eae0bb7ccadd2ef5670 Juan Pablo Garcia Dalolla committed Aug 20, 2011
Showing with 16 additions and 12 deletions.
  1. +12 −7 examples/blobs.js
  2. +2 −2 lib/waz-blobs/blob.js
  3. +2 −3 lib/waz-storage/core-service.js
View
@@ -7,7 +7,7 @@ waz.blobs.container.create('container1', function(err, container1){
console.log(err || container1);
waz.blobs.container.create('container2', function(err, container2){
- console.log('\n_________| creating a container |_________\n');
+ console.log('\n_________| creating another container |_________\n');
console.log(err || container2);
waz.blobs.container.list(function(err, containers){
@@ -32,11 +32,11 @@ waz.blobs.container.create('container1', function(err, container1){
console.log(err || blobs)
});
- container1.setAcl('container', function(err){
+ container1.setAcl('container', function(err, container){
console.log('\n_________| setting container acl to `container` |_________\n');
console.log(err || 'container acl set to `container`');
- container1.getAcl(function(err, acl){
+ container.getAcl(function(err, acl){
console.log('\n_________| displaying container acl |_________\n');
console.log(err || acl);
});
@@ -49,7 +49,12 @@ waz.blobs.container.create('container1', function(err, container1){
container1.getBlob('Folder/hello world.xml', function(err, blob){
console.log('\n_________| getting a blob |_________\n');
console.log(err || blob);
-
+
+ blob.copy('container2/Folder/helloCopy.xml', function(err, newBlob){
+ console.log('\n_________| copying a blob |_________\n');
+ console.log(err || newBlob);
+ });
+
blob.getContents(function(err,data){
console.log('\n_________| displaying blob contents |_________\n');
console.log(err || data);
@@ -73,16 +78,16 @@ waz.blobs.container.create('container1', function(err, container1){
blob.destroy(function(err){
console.log('\n_________| destroying a blob |_________\n');
- console.log(err || 'blob ' + blob.path + ' removed!');
+ console.log(err || 'blob `' + blob.path + '` removed!');
waz.blobs.container.delete('container1', function(err){
console.log('\n_________| removing a container |_________\n');
- console.log(err || 'container1 container removed!');
+ console.log(err || '`container1` container removed!');
});
waz.blobs.container.delete('container2', function(err){
console.log('\n_________| removing a container |_________\n');
- console.log(err || 'container2 container removed!');
+ console.log(err || '`container2` container removed!');
});
});
});
View
@@ -23,7 +23,7 @@ Blob.prototype.metadata = function(callback) {
};
Blob.prototype.putProperties = function(properties, callback) {
- serviceInstance.setBlobProperties(this.path, properties, function(err) {
+ serviceInstance.setBlobProperties(this.path, properties, function(err) {
callback(err);
});
};
@@ -50,7 +50,7 @@ Blob.prototype.copy = function(destination, callback){
serviceInstance.copyBlob(this.path, destination, function(err) {
if (!err) {
serviceInstance.getBlobProperties(destination, function(err, data){
- var blob = new Blob({name: destination, url: serviceInstance.generateRequestUri(destination) , contentType: data['Content-Type']})
+ var blob = new Blob({name: destination, url: serviceInstance.generateRequestUri(destination) , contentType: data['Content-Type'], serviceInstance: serviceInstance})
callback(err, blob);
});
} else {
@@ -147,17 +147,16 @@ CoreService.prototype.execute = function(verb, path, query, headers, payload, ca
method: verb,
headers: headers
};
-
+
var request = require(parsedUrl.protocol.replace(':','')).request(options, function(response) {
response.setEncoding('utf8');
var body = [];
- response.addListener('data', function (chunk) {
+ response.addListener('data', function (chunk) {
body.push(chunk);
});
response.addListener('end', function () {
-
if (response.statusCode >= 400)
error = { statusCode: response.statusCode };
else

0 comments on commit f0959ef

Please sign in to comment.