我已经将文本blob上传到azure存储(使用UploadTextASync) . 一切都很好,甚至在同一个工作站上再次下载 . 问题是当我尝试从其他服务器(阶段)下载它时:
-
对blob.ExistsAsync的调用报告blob在那里;
-
The call to blob.DownloadTextAsync returns an empty string
Build :
-
上传的文字是html,UTF8编码;
-
upload使用BlobRequestOptions和从CachingKeyResolver获得的IKey,该密钥在密钥库中生成密钥;
-
download使用BlobRequestOptions和CachingKeyResolver获取相同的密钥
事情检查到目前为止:
-
blob连接字符串在本地和舞台服务器之间是相同的;
-
密钥库名称,客户端ID,客户端密钥和blob URL在本地和舞台服务器之间都是相同的;
-
将WindowsAzure.Storage更新到最新版本(7.2.1),即使使用的旧版本(6.2.0)表现相同;
-
加密机制正在同一个项目中成功使用(上传/下载八位字节流);唯一的区别在于使用的方法
概括:
- DownloadText(及其async方法)从其他计算机调用时返回空字符串
码:
public async Task<bool> UploadTextAsync(UploadTextBlobParameter parameter)
{
var container = await EnsureBlobContainerAsync(parameter);
var blob = container.GetBlockBlobReference(parameter.Path);
var blobRequestOptions = await _blobRequestOptionsManager.GetUploadBlobRequestOptions().ConfigureAwait(false);
var exists = await blob.ExistsAsync(blobRequestOptions, null).ConfigureAwait(false);
if (!parameter.Overwrite && exists)
{
return false;
}
await blob.UploadTextAsync(parameter.InputStream, parameter.Encoding, null, blobRequestOptions, null).ConfigureAwait(false);
return true;
}
public async Task<string> DownloadTextAsync(DownloadTextBlobParameter parameter)
{
var container = await EnsureBlobContainerAsync(parameter);
var blob = container.GetBlockBlobReference(parameter.Path);
var blobRequestOptions = _blobRequestOptionsManager.GetDownloadBlobRequestOptions();
var exists = await blob.ExistsAsync(blobRequestOptions, null).ConfigureAwait(false);
if (exists)
{
return await blob.DownloadTextAsync(parameter.Encoding, null, blobRequestOptions, null).ConfigureAwait(false);
}
return null;
}
提前致谢!