question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set a Content-Type

See original GitHub issue

Hi,

I have followed Background image thumbnail processing with Azure Functions and NodeJS article to create Azure functions.It is working fine. The problem which I have is, how to set the Content-Type on the thumbnailed image.At this moment it is Stream.

function.json

{
  "bindings": [
    {
      "name": "myBlob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "project2-photos-original/{name}",
      "connection": "thumbnailfunction_STORAGE",
      "dataType": "binary"
    },
    {
      "type": "blob",
      "name": "$return",
      "path": "project2-photos-thumbnail/{name}",
      "connection": "thumbnailfunction_STORAGE",
      "direction": "out"
    }
  ],
  "disabled": false
}

I have tried as shown below.But it is not working.

index.json

var Jimp = require("jimp");

module.exports = (context, myBlob) => {

    // Read image with Jimp
    Jimp.read(myBlob).then((image) => {

        // Manipulate image
        image
            .resize(200, Jimp.AUTO)
            .greyscale()
            .getBuffer(Jimp.MIME_JPEG, (error, stream) => {
   
                if (error) {
                    context.log(`There was an error processing the image.`);
                    context.done(error);
                }
                else {
                                
                     context.res = { headers: {
                        'Content-Type': Jimp.MIME_JPEG
                     }};
                    context.log(`Successfully processed the image`);
                    context.done(null, stream);

                }

            });

    });

};


Alt Text

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mamasocommented, Jan 25, 2017

Great, happy to help, have a good one!

1reaction
mamasocommented, Jan 25, 2017

It seems that you’re using your function to create the thumbnails, once they’re created and uploaded in the blob (which your original function should accomplish, without the content-type) I think you can use an <img src="path/to/blob/thumbnail"> in your UI (assuming html based).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create and configure a new Document Set content type
Configure or customize a Document Set content type · On the Site Actions menu, click Site Settings. · Under Galleries, click Site content...
Read more >
How to set the Content-Type header for an HttpClient ...
I'm trying to set the Content-Type header of an HttpClient object as required by an API I am calling. I tried setting the...
Read more >
Content-Type - HTTP - MDN Web Docs - Mozilla
In responses, a Content-Type header provides the client with the actual content type of the returned content. This header's value may be ignored ......
Read more >
Set Default Content Type using PowerShell
Navigate to the SharePoint Online list or library where content types need to be managed. · Go to List or Library Settings >>...
Read more >
SharePoint Document Set content type
Create a Document Set Content Type · Click on the settings gear and select Site settings. · Under Web Designer Galleries, click on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found