Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
subclass BlobServiceEx
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Zinkovsky committed Jun 5, 2012
1 parent df713da commit 86d68f5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
36 changes: 20 additions & 16 deletions lib/cli/iaas/blobserviceex.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* BlobServiceEx
*/

var azure = require('../../azure');
var util = require('util');
var BlobService = require('../../services/blob/blobservice');
var WebResource = require('../../http/webresource');
var azureutil = require('../../util/util');
Expand All @@ -30,27 +30,31 @@ var BlobConstants = Constants.BlobConstants;
var HttpConstants = Constants.HttpConstants;

//Expose 'BlobServiceEx'.
//exports = module.exports = BlobServiceEx;
exports = module.exports = BlobServiceEx;


/**
* Creates a new BlobService object.
* If no storageaccount or storageaccesskey are provided, the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY environment variables will be used.
* Creates a new BlobServiceEx object.
*
* @constructor
* @extends {BlobServiceEx}
*
* @param {string} [storageAccount] The storage account.
* @param {string} [storageAccessKey] The storage access key.
* @param {string} [host] The host address.
* @param {object} [authenticationProvider] The authentication provider.
*/
azure.createBlobServiceEx = function (storageAccount, storageAccessKey, host, authenticationProvider) {
var blobService = new BlobService(storageAccount, storageAccessKey, host, authenticationProvider);
blobService.apiVersion = '2012-02-12';
return blobService;
};
function BlobServiceEx(storageAccount, storageAccessKey, host, authenticationProvider) {
BlobServiceEx.super_.call(this, storageAccount, storageAccessKey, host, authenticationProvider);
this.apiVersion = '2012-02-12';
}

util.inherits(BlobServiceEx, BlobService);

/**
* Copies a blob to a destination within the storage account. The Copy Blob operation copies the entire committed blob.
*
* @this {BlobService}
* @this {BlobServiceEx}
* @param {string} sourceContainer The source container name.
* @param {string} sourceBlob The source blob name.
* @param {string} targetContainer The target container name.
Expand All @@ -61,12 +65,12 @@ azure.createBlobServiceEx = function (storageAccount, storageAccessKey, host, au
* @param {string} [optionsOrCallback.leaseId] The target blob lease identifier.
* @param {string} [optionsOrCallback.sourceLeaseId] The source blob lease identifier.
* @param {object} [optionsOrCallback.accessConditions] The access conditions. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
* @param {object} [optionsOrCallback.sourceAccessConditions] The access conditions. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
* @param {object} [optionsOrCallback.sourceAccessConditions] The access conditions. See http://msdn.microsoft.com/en-us/library/dd179371.aspx for more information.
* @param {int} [optionsOrCallback.timeoutIntervalInMs] The timeout interval, in milliseconds, to use for the request.
* @param {function(error, blob, response)} callback The callback function.
* @return {undefined}
*/
BlobService.prototype.copyBlobEx = function (sourceUri, targetContainer, targetBlob, optionsOrCallback, callback) {
BlobServiceEx.prototype.copyBlobEx = function (sourceUri, targetContainer, targetBlob, optionsOrCallback, callback) {
var options = null;
if (typeof optionsOrCallback === 'function' && !callback) {
callback = optionsOrCallback;
Expand All @@ -91,7 +95,7 @@ BlobService.prototype.copyBlobEx = function (sourceUri, targetContainer, targetB
}

webResource.withOkCode(HttpConstants.HttpResponseCodes.ACCEPTED_CODE);

if (options && options.snapshotId) {
sourceUri += '?snapshot=' + options.snapshotId;
}
Expand All @@ -118,14 +122,14 @@ BlobService.prototype.copyBlobEx = function (sourceUri, targetContainer, targetB

next(responseObject, finalCallback);
};

this.performRequest(webResource, null, options, processResponseCallback);
};

/**
* Copies a blob to a destination within the storage account. The Copy Blob operation copies the entire committed blob.
*
* @this {BlobService}
* @this {BlobServiceEx}
* @param {string} targetContainer The target container name.
* @param {string} targetBlob The target blob name.
* @param {object|function} [optionsOrCallback] The blobs and request options.
Expand All @@ -135,7 +139,7 @@ BlobService.prototype.copyBlobEx = function (sourceUri, targetContainer, targetB
* @param {function(error, blob, response)} callback The callback function.
* @return {undefined}
*/
BlobService.prototype.copyBlobStatus = function (targetContainer, targetBlob, optionsOrCallback, callback) {
BlobServiceEx.prototype.copyBlobStatus = function (targetContainer, targetBlob, optionsOrCallback, callback) {
var options = null;
if (typeof optionsOrCallback === 'function' && !callback) {
callback = optionsOrCallback;
Expand Down
6 changes: 3 additions & 3 deletions lib/cli/iaas/upload/pageBlob.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var fs = require('fs');
var util = require('util');
var crypto = require('crypto');
var azure = require('../../../azure');
require('../blobserviceex');
var BlobServiceEx = require('../blobserviceex');
var jobTracker = require('./jobTracker');
var intSet = require('./intSet');
var blobInfo = require('./blobInfo');
Expand Down Expand Up @@ -74,9 +74,9 @@ var copyBlob =
if (!splitDestination.accountName || !splitDestination.blobName) {
throw new Error('Destination is not well formed :' + destinationUri);
}

// Using default host provided by Node SDK if not specified
var blobServiceEx = azure.createBlobServiceEx(splitDestination.accountName, destinationAccountKey, splitDestination.host);
var blobServiceEx = new BlobServiceEx(splitDestination.accountName, destinationAccountKey, splitDestination.host);

blobServiceEx.copyBlobEx(sourceUri, splitDestination.container || '$root', splitDestination.blobName, checkStatus);

Expand Down

0 comments on commit 86d68f5

Please sign in to comment.