azure-function-express
azure-function-express copied to clipboard
Support for multi-part file uploads
Have you tested multi-part file uploads with this adapter? All attempts I've tried thus far cause the web request via postman to not respond and usually timeout after 5 minutes. I also usually see this log in the function portal editor:
2017-06-21T05:04:30.644 Microsoft.Azure.WebJobs.Host: Timeout value of 00:05:00 was exceeded by function: Functions.FileUpload.
I've tried using the multer middleware with both it's memory storage as well as multer-azure to attempt to store uploads into azure blob storage.
I've also tried using busboy directly with req.pipe(busboy)
to no avail.
It's likely there is a problem with my code (and I can give some examples of what I'm trying per the above) but wanted to verify if it should work before I spend too much more time on it.
Thanks.
It seems like the issue might be caused from azure-function-express
's IncomingMessage only being an EventEmitter
and not a stream like express/node's IncomingMessage.
@techniq did you found a workaround? Feel free to submit a PR
I did not, but haven't looked into it in a while. I also haven't tried since the new functions runtime came out. This might be related to the issue as well - https://github.com/Azure/azure-webjobs-sdk-script/issues/1361
Also related
- https://github.com/Azure/azure-webjobs-sdk-script/issues/2009
- https://blogs.technet.microsoft.com/livedevopsinjapan/2017/10/07/image-uploading-with-azure-functions-node-js-and-angular-4/
This is currently low priority on my list of things at the moment. This initially came up when I was experimenting with the Functions platform. I've already been switching a lot of my development over to C# in some cases.
@techniq do you think if we return the raw Buffer
that may helps?
See in OutgoingMessage.js:
/**
* @param {Object|string|Buffer} body Express/connect body object
* @param {string} encoding
* @returns {Object|string} Azure Function body
*/
function convertToBody(body, encoding) {
// This may be removed on Azure Function native support for Buffer
// https://github.com/Azure/azure-webjobs-sdk-script/issues/814
// https://github.com/Azure/azure-webjobs-sdk-script/pull/781
return Buffer.isBuffer(body)
? body.toString(encoding)
: body;
}
Related to https://github.com/Azure/azure-webjobs-sdk-script/issues/814 and https://github.com/Azure/azure-webjobs-sdk-script/pull/781
Hey guys, I was having the same issue. Looks like it's a problem between the structure of the Express Request object vs. the Azure Context Request object. It looks like one of those is not being treated as a Buffer, but I can elaborate more on the issue, since I saw this discussion somewhere else. I'll try to find the link for that discussion.
As a alternative, I've been uploading files transforming them to Base64 and sending then via Form Data
Can we now use multer as normal ?
no, multer is still not working with this
From my observations with current state of azure functions (v2) for js it might be pointless to invest in support of this. All requests come via starter function which only gets triggered once entire request was loaded. At this point there is no streaming, if uploaded files made it to your starter function you can use something like https://www.npmjs.com/package/multipart-formdata to parse uploaded files. You can get boundary from req.headers
and body from req.body
. Result will be similar to multer with memory storage.
https://www.builtwithcloud.com/multipart-form-data-processing-via-httptrigger-using-nodejs-azure-functions/
Is multi-part in Azure Functions (for Javascript) still unsupported?
@yvele it appears you are busy, but some feedback on this would be greatly appreciated. I opted to use this library, and this is really killing me. It appears there is a PR in place to deal with the IncomingMessage
not being a readable stream. This seems like a likely fix. Are youworking on this project at all anymore or has this been officially abandoned?