Set a Content-Type
See original GitHub issueHi,
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);
}
});
});
};
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great, happy to help, have a good one!
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).