从 Windows 通用应用程序将 StorageItemThumbnail 上传到 Azure blob 存储
Uploading a StorageItemThumbnail to Azure blob storage from a Windows Universal app
我正在构建一个 Windows 通用应用程序。
我有一个Windows.Storage.FileProperties.StorageItemThumbnail obtained from a Windows.Storage.StorageFile as the result of a call to StorageFile.GetThumbnailAsync。
现在我需要将缩略图上传到 Azure blob 存储。
Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob
上的正确方法似乎是 UploadFromFileAsync
或 UploadFromStreamAsync
。
但我能找到的关于 UploadFromFileAsync is misleading in my case. All the method overloads documented there include a System.IO.FileMode 参数的唯一文档,在 Windows Runtime / Windows Universal 下不可用。这些是我实际可用的两个重载:
public IAsyncAction UploadFromFileAsync(StorageFile source);
public IAsyncAction UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext);
虽然我不知道在哪里可以找到它们的记录。
如何使用 CloudBlockBlob
将 StorageItemThumbnail
上传到 Azure blob 存储?
原来很直白:
public async void UploadThumbnailToBlob(Windows.Storage.FileProperties.StorageItemThumbnail thumbnail, Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob blob)
{
await blob.UploadFromStreamAsync(thumbnail);
}
我正在构建一个 Windows 通用应用程序。
我有一个Windows.Storage.FileProperties.StorageItemThumbnail obtained from a Windows.Storage.StorageFile as the result of a call to StorageFile.GetThumbnailAsync。
现在我需要将缩略图上传到 Azure blob 存储。
Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob
上的正确方法似乎是 UploadFromFileAsync
或 UploadFromStreamAsync
。
但我能找到的关于 UploadFromFileAsync is misleading in my case. All the method overloads documented there include a System.IO.FileMode 参数的唯一文档,在 Windows Runtime / Windows Universal 下不可用。这些是我实际可用的两个重载:
public IAsyncAction UploadFromFileAsync(StorageFile source);
public IAsyncAction UploadFromFileAsync(StorageFile source, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext);
虽然我不知道在哪里可以找到它们的记录。
如何使用 CloudBlockBlob
将 StorageItemThumbnail
上传到 Azure blob 存储?
原来很直白:
public async void UploadThumbnailToBlob(Windows.Storage.FileProperties.StorageItemThumbnail thumbnail, Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob blob)
{
await blob.UploadFromStreamAsync(thumbnail);
}