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

Array of files to upload in single files property fails #120

Open
mrcnk opened this issue Nov 29, 2023 · 6 comments
Open

Array of files to upload in single files property fails #120

mrcnk opened this issue Nov 29, 2023 · 6 comments

Comments

@mrcnk
Copy link

mrcnk commented Nov 29, 2023

Hi, thanks for this action, helps a lot.

I'd like the multipart/form-data files upload to work like:

files: '{"attachments": ["report.html", "report.json"]}'

This is what a CMS I use for one of my apps accepts.
Using it with the action produces:

{"message":"Unable to convert Data and Files into FormData: The \"path\" argument must be of type string or an instance of Buffer or URL. Received an instance of Array","data":{"jobId":"u4oigjysc5lzwkg"},"files":{"attachments":["report.html","report.json"]}}
@fjogeleit
Copy link
Owner

fjogeleit commented Nov 29, 2023

hey, I'll have a look. What would be the expected key?

{
 "files[0]": "report.html file",
 "files[1]":" report.json file"
}

something like this?

@mrcnk
Copy link
Author

mrcnk commented Nov 29, 2023

Thanks for a quick reply, so the correct data for my CMS patch is:

CleanShot 2023-11-29 at 11 43 05@2x

Looks like it just doubles the same key without array index for the form data.

@fjogeleit
Copy link
Owner

fjogeleit commented Nov 30, 2023

Could you please test if its working with fjogeleit/http-request-action@support-file-array?

I added a basic test action, so it looks good but would like your confirmation before I release it.

@mrcnk
Copy link
Author

mrcnk commented Nov 30, 2023

Sure, so my step looks like this:

- name: Upload Report
    uses: fjogeleit/http-request-action@support-file-array
    with:
      url: [Endpoint URL]
      method: POST
      contentType: multipart/form-data
      bearerToken: ${{ secrets.API_ADMIN_SECRET_KEY }}
      customHeaders: '{"Content-Type": "application/json"}'
      data: '{"jobId": "${{ github.event.inputs.jobId }}"}'
      files: '{"attachments": [".lighthouseci/report.html", ".lighthouseci/report.json"]}'

And when executed, I get a mimetype error:

{"code":400,"message":{"code":400,"message":"Something went wrong while processing your request.","data":{"attachments":{"code":"validation_invalid_mime_type","message":"\"report_vETdVgmY8E.html\" mime type must be one of: text/html, application/pdf, image/png, image/jpeg, application/json."}}}}

However, as you can see in the error message, text/html is allowed.

@fjogeleit
Copy link
Owner

okay, thanks. I will check it.

@fjogeleit
Copy link
Owner

sorry for the late response, can you find out what contentType the files have in your case? I tried different things and in the debug logs the content types look correct, so I am wondering what your backend receives as content type.

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

2 participants