nativescript-azure-storage
NativeScript 的 Azure 存储
npm i --save nativescript-azure-storage

npm npm

nativescript-azure-storage

安装

tns plugin add nativescript-azure-storage

用法

import { NativeScriptAzureStorage } from 'nativescript-azure-storage';
let azureStorage = new NativeScriptAzureStorage(this.azureStorageConnectionString);

Android 和 iOS 可用的方法

createBlobContainer:创建 blob 容器

azureStorage.createBlobContainer('blobContainer')
.then(() => console.log(`Blog container Created!`))
.catch((err) => console.log(`Error creating blob container: ${err}`));

deleteBlobContainer:删除 blob 容器

azureStorage.deleteBlobContainer('blobContainer')
.then(() => console.log(`Blog container deleted!`))
.catch((err) => console.log(`Error deleting blob container: ${err}`));

uploadBlob:上传 blob

azureStorage.uploadBlob('blobContainer', 'blobName', 'Hello World!')
.then(() => console.log(`Uploaded successfuly`))
.catch((err) => console.log(`Error uploading: ${err}`));

deleteBlob:删除 blob

azureStorage.deleteBlob('blobContainer', 'blobName')
.then(() => console.log(`Blob deleted successfuly`))
.catch((err) => console.log(`Error deleting blob: ${err}`));

downloadBlob:下载 blob

azureStorage.downloadBlob('blobContainer', 'blobName')
.then((blob) => console.log(`Blob downloaded successfuly`))
.catch((err) => console.log(`Error getting tables: ${err}`));

仅限 Android 的方法(目前)

createTable:使用指定名称创建表

azureStorage.createTable('table')
.then(() => console.log(`Table Created!`))
.catch((err) => console.log(`Error creating table: ${err}`));

addRow:从对象中插入新行

azureStorage.addRow('table', { foo: 'bar' }, 'partitionKey', 'rowKey')
.then(() => console.log(`Row created successfuly!`))
.catch((err) => console.log(`Error creating row: ${err}`));

addRows:从对象列表中插入新行

let array = new Array<any>();
array.push({ foo: 'bar' });
azureStorage.addRows('table', 'partitionKey', 'foo', array)
.then(() => console.log(`Rows created successfuly!`))
.catch((err) => console.log(`Error creating rows: ${err}`));

listTables:列出存储中的所有表

azureStorage.listTables()
.then((tables) => {
tables.forEach((table) => {
console.log(`Table:${table}`);
});
})
.catch((err) => console.log(`Error getting tables: ${err}`))
;

listRows:列出指定表中的所有行

azureStorage.listRows('table')
.then((rows) => {
rows.forEach((row) => {
console.log(`Row:${row.partitionKey} | ${row.rowKey} | ${row.getTimestamp() }`);
});
})
.catch((err) => console.log(`Error getting rows: ${err}`))
;

下一个版本(即将推出)

updateRow;

deleteRow;

iOS 的表格方法