-
Notifications
You must be signed in to change notification settings - Fork 0
GetBlobMethod
Michael J. Ryan edited this page May 21, 2015
·
1 revision
The azure-config-util object instance presents a blob(name) method that returns a promise, that will resolve to an azure-storage-simple blob instance.
This method uses storage(...) to establish an azure-storage-simple connection wrapper.
| Section | Key | JsonValue |
|---|---|---|
| blob | somecontainer | {"storage":"account", "name": "somecontainername"} |
- The shown
"name"field in theJsonValueis optional when it matches theKey.
-
storage- specifies the named storage account to use (see storage(...)) -
name- the name of the storage queue to create/use -
options- object to use with the underlying createQueueIfNotExists-
publicAccessLevel: string, enumeration value- default - Private
-
"container"- blobs and container attributes/queries are public -
"blob"- blobs themselves are public
-
// when there's no matching Key, or no "storage" is specified
// under the covers: azureUtil.storage().blob('unspecifiedcontainer',options);
let someUnspecifiedContainer = await azureUtil.blob('unspecifiedcontainer',options);
// when there is a matching key
// under the covers: azureUtil.storage('account').blob('somecontainername');
let blob = await azureUtil.blob('somecontainer');
// ### write(path,[options],data) ###
// application/octet-stream (default)
let result = await blob.write('some/path/file.ext', someBuffer);
// text/plain, charset=UTF-8
result = await blob.write('some/path/file.txt', someString);
// application/json
result = await blob.write('some/path/file.json', someObjectOrArray);
// specified type
var result = await blob.write(
'some/path/image.png'
,{
contentType: 'image/png'
//,contentEncoding: 'gzip' // specify encoding if you 'gzip' or 'deflate' your content
}
,imageBuffer
);
// ### read(path,[options]) => Buffer ###
var myBuffer = await blob.read('some/path/file.txt');
var myText = myBuffer.toString(); //decode from utf8 / default
...
var myBuffer = await blob.read('some/path/file.json');
var myObj = JSON.parse(myBuffer.toString()); //decode stored json above..
// ### delete(path,[options])
await blob.delete('some/path/file.ext');