Tag: azure storage blobs

在azure blob存储中原位创建zip文件

我将文件存储在blob存储帐户中的一个容器中。 我需要在第二个容器中创建一个zip文件,其中包含第一个容器中的文件。 我有一个使用worker角色和DotNetZip工作的解决方案,但因为zip文件最终可能是1GB大小我担心使用MemoryStream对象进行所有正在进行的工作并不是最好的方法。 我最关心的是内存使用和释放资源,因为这个过程可能每天发生几次。 下面是一些非常简化的代码,显示了worker角色的基本过程: using (ZipFile zipFile = new ZipFile()) { foreach (var uri in uriCollection) { var blob = new CloudBlob(uri); byte[] fileBytes = blob.DownloadByteArray(); using (var fileStream = new MemoryStream(fileBytes)) { fileStream.Seek(0, SeekOrigin.Begin); byte[] bytes = CryptoHelp.EncryptAsBytes(fileStream, “password”, null); zipFile.AddEntry(“entry name”, bytes); } } using (var zipStream = new MemoryStream()) { zipFile.Save(zipStream); […]

在Azure Blob存储上强制下载IE9文件

我正在尝试使用Azure Blob存储作为使用共享访问签名进行安全文件下载的位置。 一切都运行良好,但我遇到的问题是我试图让用户从浏览器保存文件,我有除IE9以外的所有浏览器工作。 回顾这个问题, 什么内容类型强制下载文本响应? 当我可以控制所有标题时,这很有效,但是在Azure Blob存储中,我已将Content-Type设置为application / octet-stream,这允许除IE之外的所有浏览器都要求用户保存文件,IE只是打开文件。 看来已知的文件类型将打开(例如.jpg,.wmv等…)。 在Azure中,我发现无法设置 Content-Disposition: attachment;filename=”My Text File.txt” 有没有办法,使用Azure Blob存储,使用IE直接从Azure Blob存储下载任何文件? 提前致谢。

如何使用c#读取在blob中捕获的事件中心日志数据

我有simple logic app , creates a text file 我想test whether the logic app created file is present in file storage 。 并且还想测试correlation id of logic app的correlation id of logic app的值 我创建了Event Hub和In Logic app configure Diagnostic Settings to Stream to an event hub 。 现在Inside Event hub I have configure Capture option to Azure Storage […]

Azure Blob不存储PDF

好的,我有以下代码 – 它适用于存储jpgs,但不存储pdfs。 知道为什么吗? public bool TryStoreImage(string uri, string fileName) { try { WebClient wc = new WebClient(); var blob = new BlobStorage().GetCloudBlobContainer(); var store = blob.GetBlobReference(fileName); store.UploadByteArray(wc.DownloadData(uri)); return true; } catch (Exception exc) { return false; } } ` 再次,我试图访问的每个pdf给我“pdf不存在”,即使我可以在azure色管理屏幕中看到pdf。 然而,我存储的每个jpg都是完全可访问的。

在Async方法中绑定到输出blob时,将Blob绑定到IAsyncCollector时出错

我试图在这篇文章之后绑定到Async方法中的blob输出: 如何将输出值绑定到我的异步Azure函数? 我有多个输出绑定,所以只返回不是一个选项 public static async Task Run(HttpRequestMessage req, IAsyncCollector collection, TraceWriter log) { if (req.Method == HttpMethod.Post) { string jsonContent = await req.Content.ReadAsStringAsync(); // Save to blob await collection.AddAsync(jsonContent); return req.CreateResponse(HttpStatusCode.OK); } else { return req.CreateResponse(HttpStatusCode.BadRequest); } } 我对blob的绑定是: { “bindings”: [ { “authLevel”: “function”, “name”: “req”, “type”: “httpTrigger”, “direction”: “in” }, { “name”: […]

上传时从video中抓取缩略图。 (Azure Blob存储)

我目前有一个系统可以将video上传到Azure blob存储并且工作正常。 我想实现一个function,在上传时抓取video中的缩略图,并将其推送到Azure。 我按照建议尝试使用它: new FFMpegConverter().GetVideoThumbnail(file, outputJPEG); 问题是我不知道什么用作outputJPEG,因为我没有写入的文件,而是想将该文件写入Azure的blob存储。 任何人都可以帮我解决这个问题,或者建议另一种方法吗? 我试过了: 创建一个新的空HttpPostedFileBase作为outputJPEG文件,但这是不可能的,因为它只接受用户上传的文件。 使用文件流,但这似乎不起作用,因为它需要写入的文件的位置,而不是让我只是推送到blob存储。 (来自:blob.UploadFromStream(file.InputStream);) 在此先感谢您的帮助!

将DataTable上载到Azure blob存储

我正在尝试将DataTable序列化为XML,然后将其上载到Azure blob存储。 下面的代码有效,但看起来很笨重,内存很饿。 有一个更好的方法吗? 我特别指的是我将内存流转储到字节数组然后从中创建新的内存流。 var container = blobClient.GetContainerReference(“container”); var blockBlob = container.GetBlockBlobReference(“blob”); byte[] blobBytes; using (var writeStream = new MemoryStream()) { using (var writer = new StreamWriter(writeStream)) { table.WriteXml(writer, XmlWriteMode.WriteSchema); } blobBytes = writeStream.ToArray(); } using (var readStream = new MemoryStream(blobBytes)) { blockBlob.UploadFromStream(readStream); }

如何跟踪乱序的单个对象,然后连续加入()连续的对象?

我首先要说的是比一起盲目加入byte[]要困难一些。 我的主要目标是优化当前将许多512字节页面上传到Web服务器(Azure页面Blob)的应用程序,并将其减少为4Megs或更少的单个大型上载。 有关原因的更多背景信息,请参阅此问题底部的链接。 简要回答原因:通过使用Azure稀疏文件,此优化将提高速度(更少的IO)并节省长期资金 现在详细说明: 该课程需要 接受数据并存储它(数据定义为alignment start , alignment stop和随附的有效负载。 在N个数据到达或发生event , ProcessData() 。 这意味着是时候根据边界组装数据了( blob1的停止值必须与blob1对齐) 连续数据实际上可能无序到达。 非连续数据定义为在调用processData()之前调用应用程序未发送它时。 此外,如果整个512字节范围==零,那么它将获得特殊处理,并被视为非连续。 我们正在处理byte []的类型,因此这里有效的列表可能很复杂。 我想避免不必要的副本和数组的扩展。 合理? (像泥,我希望不是) 到目前为止我最接近的是编写方法签名:(我知道很蹩脚) // This can’t be bigger than 4Mb, or smaller than 512 byte[] BigBlobToUpload = new byte[]; /// /// Collects consecutive data ranges that will be uploaded /// /// The […]

来自MemoryStream的AddAttachment

SendGrid API文档指定您可以从Stream添加附件。 它给出的示例使用FileStream对象 。 我在Azure存储中有一些blob,我想将其作为附件发送电子邮件。 要实现这一点,我正在尝试使用MemoryStream : var getBlob = blobContainer.GetBlobReferenceFromServer(fileUploadLink.Name); if(getBlob != null) { // Get file as a stream MemoryStream memoryStream = new MemoryStream(); getBlob.DownloadToStream(memoryStream); emailMessage.AddAttachment(memoryStream, fileUploadLink.Name); } emailTransport.Deliver(emailMessage); 它发送正常,但当电子邮件到达时,附件似乎在那里,但它实际上是空的。 查看电子邮件来源,附件没有内容。 在使用SendGrid C#API发送附件时,使用MemoryStream是一个已知的限制吗? 或者我应该以其他方式接近这个?

Azure,存储2.0的共享访问签名上的访问被拒绝

我无法获得共享访问签名以使用Storage 2.0 .. 我用的代码是: if (blob.Exists()) { var expires = DateTime.UtcNow.AddMinutes(30); var sas = blob.GetSharedAccessSignature(new Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy { Permissions = Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions.Read, SharedAccessExpiryTime = expires }); url = string.Concat(blob.Uri.AbsoluteUri, sas); } return url; 但是如果我调试会话并将URL粘贴到浏览器中,我会收到错误: AuthenticationFailed Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:c1a1dd2b-bf4a-4a6b-bab2-ab1cb9363d27 Time:2012-11-19T14:41:51.1254531Z Signature […]