【发布时间】:2014-02-15 14:49:49
【问题描述】:
我有以下代码将图像上传到 Azure blob 存储。我想在上传到 blob 之前加密图像数据。我已经有一个用于加密和解密的辅助类,我可以通过调用 AESEncryption.Encrypt("plainText", "key", salt");
我只是想弄清楚汤姆如何将我的加密方法集成到代码中。另外,我猜一旦它被加密而不是调用 blob.UploadFromFile() 我将调用 blob.UploadFromByteArray()。
public override Task ExecutePostProcessingAsync()
{
try
{
// Upload the files to azure blob storage and remove them from local disk
foreach (var fileData in this.FileData)
{
var filename = BuildFilename(Path.GetExtension(fileData.Headers.ContentDisposition.FileName.Trim('"')));
// Retrieve reference to a blob
var blob = _container.GetBlockBlobReference(filename);
blob.Properties.ContentType = fileData.Headers.ContentType.MediaType;
blob.UploadFromFile(fileData.LocalFileName, FileMode.Open);
File.Delete(fileData.LocalFileName);
Files.Add(new FileDetails
{
ContentType = blob.Properties.ContentType,
Name = blob.Name,
Size = blob.Properties.Length,
Location = blob.Uri.AbsoluteUri
});
}
}
catch (Exception ex)
{
throw ex;
}
return base.ExecutePostProcessingAsync();
}
【问题讨论】:
标签: c# .net asp.net-mvc azure azure-blob-storage