1. <i id='qfkcq'><tr id='qfkcq'><dt id='qfkcq'><q id='qfkcq'><span id='qfkcq'><b id='qfkcq'><form id='qfkcq'><ins id='qfkcq'></ins><ul id='qfkcq'></ul><sub id='qfkcq'></sub></form><legend id='qfkcq'></legend><bdo id='qfkcq'><pre id='qfkcq'><center id='qfkcq'></center></pre></bdo></b><th id='qfkcq'></th></span></q></dt></tr></i><div id='qfkcq'><tfoot id='qfkcq'></tfoot><dl id='qfkcq'><fieldset id='qfkcq'></fieldset></dl></div>
      <bdo id='qfkcq'></bdo><ul id='qfkcq'></ul>
      <tfoot id='qfkcq'></tfoot>

      <small id='qfkcq'></small><noframes id='qfkcq'>

    1. <legend id='qfkcq'><style id='qfkcq'><dir id='qfkcq'><q id='qfkcq'></q></dir></style></legend>
    2. 在 Azure Functions 应用程序 blobtrigger 中设置 blob 的内容类型

      Setting the content-type of a blob in Azure functions app blobtrigger(在 Azure Functions 应用程序 blobtrigger 中设置 blob 的内容类型)

      <legend id='edFr0'><style id='edFr0'><dir id='edFr0'><q id='edFr0'></q></dir></style></legend>
      • <bdo id='edFr0'></bdo><ul id='edFr0'></ul>
              <tbody id='edFr0'></tbody>
            <tfoot id='edFr0'></tfoot>
              <i id='edFr0'><tr id='edFr0'><dt id='edFr0'><q id='edFr0'><span id='edFr0'><b id='edFr0'><form id='edFr0'><ins id='edFr0'></ins><ul id='edFr0'></ul><sub id='edFr0'></sub></form><legend id='edFr0'></legend><bdo id='edFr0'><pre id='edFr0'><center id='edFr0'></center></pre></bdo></b><th id='edFr0'></th></span></q></dt></tr></i><div id='edFr0'><tfoot id='edFr0'></tfoot><dl id='edFr0'><fieldset id='edFr0'></fieldset></dl></div>

              <small id='edFr0'></small><noframes id='edFr0'>

              1. 本文介绍了在 Azure Functions 应用程序 blobtrigger 中设置 blob 的内容类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试调整上传到我的容器的图像的大小,以便为我的网站创建缩略图和其他各种版本的图像.

                I am trying to resize the images uploaded to my container in order to create thumbnails and various other versions of my images for my site.

                我上传的图片必须更正内容类型image/jpeg";但是当我使用下面的代码创建它们的新版本时,结果显示为application/octet-stream".

                The images I upload have to correct content-type "image/jpeg" but when I create a new version of them using the code below it turns out as "application/octet-stream".

                我在这里错过了什么?

                using ImageResizer;
                using ImageResizer.ExtensionMethods;
                 
                public static void Run(Stream myBlob, string blobname, string blobextension, Stream outputBlob, TraceWriter log)
                {
                    log.Info($"C# Blob trigger function Processed blob
                 Name:{blobname} 
                 Size: {myBlob.Length} Bytes");
                    
                    var instructions = new Instructions
                    {
                        Width = 570,
                        Mode = FitMode.Crop,
                        Scale = ScaleMode.Both,
                    };
                    ImageBuilder.Current.Build(new ImageJob(myBlob, outputBlob, instructions));
                }
                

                解决方案.

                #r "Microsoft.WindowsAzure.Storage"
                using ImageResizer;
                using ImageResizer.ExtensionMethods;
                using Microsoft.WindowsAzure.Storage.Blob;
                
                public static void Run(Stream myBlob, string blobname, string blobextension, CloudBlockBlob outputBlob, TraceWriter log)
                {
                    log.Info($"C# Blob trigger function Processed blob
                 Name:{blobname} 
                 Size: {myBlob.Length} Bytes");
                    
                    var instructions = new Instructions
                    {
                        Width = 570,
                        Mode = FitMode.Crop,
                        Scale = ScaleMode.Both
                    };
                
                    Stream stream = new MemoryStream();
                    ImageBuilder.Current.Build(new ImageJob(myBlob, stream, instructions));
                    stream.Seek(0, SeekOrigin.Begin);
                 
                    outputBlob.Properties.ContentType = "image/jpeg";
                    outputBlob.UploadFromStream(stream);
                }
                

                推荐答案

                当你使用流输出时,函数会默认你的 content-type 为 application/octet-stream.

                When you use the stream output, functions will default your content-type to application/octet-stream.

                使用其中一种 ICloudBlob 类型,它应该允许您指定 blob 的内容类型.

                Use one of the ICloudBlob types, which should allow you to specify the content type of your blob.

                以下是可以作为参数绑定的类型的备忘单:https://jhaleyfiles2016.blob.core.windows.net/public/Azure%20WebJobs%20SDK%20Cheat%20Sheet%202014.pdf

                Here's a cheatsheet of types you can bind to as parameters: https://jhaleyfiles2016.blob.core.windows.net/public/Azure%20WebJobs%20SDK%20Cheat%20Sheet%202014.pdf

                这篇关于在 Azure Functions 应用程序 blobtrigger 中设置 blob 的内容类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                set equality in linq(在 linq 中设置相等)
                HashSet conversion to List(HashSet 转换为 List)
                How to set timeout for webBrowser navigate event(如何为 webBrowser 导航事件设置超时)
                Test whether two IEnumerablelt;Tgt; have the same values with the same frequencies(测试两个IEnumerablelt;Tgt;具有相同频率的相同值)
                How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)
                  <tbody id='m8Vb9'></tbody>

                <legend id='m8Vb9'><style id='m8Vb9'><dir id='m8Vb9'><q id='m8Vb9'></q></dir></style></legend>
                  <i id='m8Vb9'><tr id='m8Vb9'><dt id='m8Vb9'><q id='m8Vb9'><span id='m8Vb9'><b id='m8Vb9'><form id='m8Vb9'><ins id='m8Vb9'></ins><ul id='m8Vb9'></ul><sub id='m8Vb9'></sub></form><legend id='m8Vb9'></legend><bdo id='m8Vb9'><pre id='m8Vb9'><center id='m8Vb9'></center></pre></bdo></b><th id='m8Vb9'></th></span></q></dt></tr></i><div id='m8Vb9'><tfoot id='m8Vb9'></tfoot><dl id='m8Vb9'><fieldset id='m8Vb9'></fieldset></dl></div>

                  <tfoot id='m8Vb9'></tfoot>

                      <bdo id='m8Vb9'></bdo><ul id='m8Vb9'></ul>

                      <small id='m8Vb9'></small><noframes id='m8Vb9'>