我有一個MVC應用程序,其中用戶列表可以上傳文件到GoogleDrive/DropBox,爲此他們只需要驗證自己,相應的API提供了一個'AccessToken'或其他進一步用於從我的Web應用程序上傳文件到用戶帳戶。訪問登錄用戶的Azure Blob存儲
現在我需要對Azure Blob存儲做同樣的事情。爲了測試我創建了一個帳戶,並有使用帳戶名和創建Accountkey其做同樣的這樣一個連接字符串:
public void UploadFileToBlob1(string fileName, byte[] fileData)
{
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(System.Configuration.ConfigurationManager.AppSettings["StorageConnectionString"]);
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("portalcontainer");
container.CreateIfNotExists();
// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob = container.GetBlockBlobReference(fileName);
// Create or overwrite the "myblob" blob with contents from a local file.
Stream stream = new MemoryStream(fileData);
blockBlob.UploadFromStream(stream);
}
現在,我想使用戶誰登錄到我的應用程序,可以做同樣的。
因此,在Azure blob存儲的情況下,我可以如何在Blob存儲帳戶上對已登錄的用戶進行身份驗證,並獲取'accesstoken'或其他內容以在用戶blob容器上執行文件上載/下載。
請告知目前不支持Azure存儲
您是否調查過共享訪問簽名是否符合您的要求? https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-shared-access-signature-part-1/ –
是的,但共享訪問簽名也需要帳戶密鑰。 –