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

Update "@azure/functions": "^3.2.0" to "^4.0.0" #638

Open
kazto opened this issue Apr 24, 2024 · 4 comments
Open

Update "@azure/functions": "^3.2.0" to "^4.0.0" #638

kazto opened this issue Apr 24, 2024 · 4 comments

Comments

@kazto
Copy link

kazto commented Apr 24, 2024

error TS2345: Argument of type 'import("C:/work/node_modules/@azure/functions/types/http").HttpRequest' is not assignable to parameter of type 'import("C:/work/node_modules/@anzp/azure-function-multipart/node_modules/@azure/functions/types/http").HttpRequest'.
  Type 'HttpRequest' is missing the following properties from type 'HttpRequest': get, parseFormBody

29     const { fields, files } = await parseMultipartFormData(request);
                                                              ~~~~~~~

#373 is similar to this Issue, but I believe the cause is different.

@TamimiGitHub
Copy link

Bump this - facing the same issue

@LucasBonafe
Copy link

Since the library is not updated and probably won't be, would there be any other simple implementation based on its dependencies?

Using busboy directly, what would it look like...?

@TamimiGitHub
Copy link

Hey @LucasBonafe - I was able to achieve this by using the parse-multipart. To do this, you will have to read the raw body of the request as a buffer stream and make sure you extract the boundaries of the form-data using multipart. The following is an example

import * as multipart from 'parse-multipart';

# in your function

const rawBody = await request.body.getReader().read();
const contentType = request.headers.get('content-type');
const boundary = multipart.getBoundary(contentType);

if(boundary) {
try {
    let files: Form[] = multipart.Parse(Buffer.from(rawBody.value), boundary);
    # Print out all the files in the form-data body
    console.log(files)
    # Print out the content of the files
      files.map(file => context.log(file.data.toString()));
} catch (error) {
  return {status: 400, body: error};
}

@ichivers
Copy link

ichivers commented Jan 1, 2025

See #639

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

No branches or pull requests

4 participants