共有アクセスクエリ文字列urlを文字列化しようとしています。しかし、何も返しません。以下はコードです。オブジェクトを文字列化しようとするとAzure Node.jsクエリ文字列が返されません
var table = module.exports = require('azure-mobile-apps').table();
var azure = require('azure');
var qs = require('querystring');
var logger = require('azure-mobile-apps/src/logger');
// table.read(function (context) {
// return context.execute();
// });
// table.read.use(customMiddleware, table.operation);
table.insert(function (context) {
// Get storage account settings from app settings.
var accountName = 'xxx';
var accountKey = 'xxx';
var host = accountName + '.blob.core.windows.net';
if ((typeof context.item.containerName !== "undefined") && (
context.item.containerName !== null)) {
// Set the BLOB store container name on the item, which must be lowercase.
context.item.containerName = context.item.containerName.toLowerCase();
// If it does not already exist, create the container
// with public read access for blobs.
var blobService = azure.createBlobService(accountName, accountKey, host);
blobService.createContainerIfNotExists(context.item.containerName, {
publicAccessLevel: 'blob'
}, function(error) {
if (!error) {
// Provide write access to the container for the next 5 mins.
var sharedAccessPolicy = {
AccessPolicy: {
Permissions: azure.Constants.BlobConstants.SharedAccessPermissions.WRITE,
Expiry: new Date(new Date().getTime() + 5 * 60 * 1000)
}
};
// Generate the upload URL with SAS for the new image.
var sasQueryUrl =
blobService.generateSharedAccessSignature(context.item.containerName,
context.item.resourceName, sharedAccessPolicy);
// Set the query string.
context.item.sasQueryString = qs.stringify(sasQueryUrl.queryString);
// Set the full path on the new new item,
// which is used for data binding on the client.
context.item.imageUri = sasQueryUrl.baseUrl + sasQueryUrl.path;
logger.debug('h); e); l); l); o)');
logger.debug(sasQueryUrl);
logger.debug(context.item.sasQueryString);
} else {
console.error(error);
logger.error(error);
}
return context.execute();
});
} else {
return context.execute();
}
});
ロガーリターンの出力:
2016-08-16T13:50:24.820Z - debug: h); e); l); l); o)
2016-08-16T13:50:24.836Z - debug: se=2016-08-16T13%3A55%3A24Z&sp=w&sv=2015- 04-05&sr=b&sig=euf53CcO8SDqJowFBFiKPgRTpVt21HmRUlppN9piatY%3D
2016-08-16T13:50:24.852Z - debug:
あなたが問題を見ることができるようにするときSE = 2016-08-16T13%3A55%3A24Z & SP = W & SV = 2015年4月5日をoccures & sr = b & sig = euf53CcO8SDqJowFBFiKPgRTpVt21HmRUlppN9piatY%3D queryString、baseUrl、およびpathを返すことができません。
npmクエリーストリングをコンソールにインストールして実行しようとしましたが、まだ動作しません。ここで私が参照したチュートリアルです。
ポータルの新しいバージョンは、チュートリアルと互換性がありませんあまりにも悪いが、それゆえ私は1つ新しいにポートにコードを試みました。
ありがとうございます。
おそらく、カスタムAPIとしてSASトークン生成を実行する必要があります。ファイルのアップロードに関する情報については、https://shellmonger.com/2016/05/30/30-days-of-zumo-v2-azure-mobile-apps-day-27-file-handling-v1/を参照してください。 Androidチュートリアルと統合できるはずです。 –