Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multi-part file uploads #8

Open
techniq opened this issue Jun 21, 2017 · 11 comments
Open

Support for multi-part file uploads #8

techniq opened this issue Jun 21, 2017 · 11 comments

Comments

@techniq
Copy link

techniq commented Jun 21, 2017

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.

@techniq
Copy link
Author

techniq commented Jun 21, 2017

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.

@yvele
Copy link
Owner

yvele commented Oct 15, 2017

@techniq did you found a workaround? Feel free to submit a PR

@techniq
Copy link
Author

techniq commented Oct 15, 2017

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 - Azure/azure-functions-host#1361

@techniq
Copy link
Author

techniq commented Oct 15, 2017

Also related

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.

@yvele
Copy link
Owner

yvele commented Oct 18, 2017

@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 Azure/azure-functions-host#814 and Azure/azure-functions-host#781

@danfsd
Copy link

danfsd commented May 21, 2018

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

@iamchathu
Copy link

Can we now use multer as normal ?

@webuniverseio
Copy link

no, multer is still not working with this

@webuniverseio
Copy link

webuniverseio commented Oct 11, 2019

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/

@angelcervera
Copy link

Is multi-part in Azure Functions (for Javascript) still unsupported?

@jpgilchrist
Copy link

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants