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 Arrays in multipart/form-data #1367

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

shahriar-shojib
Copy link

No description provided.

Copy link

changeset-bot bot commented Oct 31, 2024

🦋 Changeset detected

Latest commit: 71e9a5c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@kubb/plugin-client Patch
@kubb/plugin-swr Patch
@kubb/cli Patch
@kubb/config-biome Patch
@kubb/config-ts Patch
@kubb/config-tsup Patch
@kubb/core Patch
@kubb/fs Patch
@kubb/oas Patch
@kubb/parser-ts Patch
@kubb/plugin-faker Patch
@kubb/plugin-msw Patch
@kubb/plugin-oas Patch
@kubb/plugin-react-query Patch
@kubb/plugin-redoc Patch
@kubb/plugin-solid-query Patch
@kubb/plugin-svelte-query Patch
@kubb/plugin-ts Patch
@kubb/plugin-vue-query Patch
@kubb/plugin-zod Patch
@kubb/react Patch
@kubb/types Patch
kubb Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kubb-labs
Copy link

kubb-labs bot commented Oct 31, 2024

The preview deployment is ready. 🟢

Open Preview | Open Build Logs

Last updated at: 2024-10-31 18:37:19 CET

@gusthavosouza
Copy link

@shahriar-shojib can we make sure this will also work for file uploading?

I had to remove the code from my client generation as it was breaking file uploading:

if(data) { Object.keys(data).forEach((key) => { const value = data[key as keyof typeof data]; if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) { formData.append(key, value); } }) }

@shahriar-shojib
Copy link
Author

@shahriar-shojib can we make sure this will also work for file uploading?

I had to remove the code from my client generation as it was breaking file uploading:

if(data) { Object.keys(data).forEach((key) => { const value = data[key as keyof typeof data]; if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) { formData.append(key, value); } }) }

I don't know why it would break because the code you sent is the existing code and it works for file uploads as long as the formData does not contain any Arrays.

I will double-check the test cases.

please add more details on how your file uploads are breaking so that I can take a closer look.

@gusthavosouza
Copy link

@shahriar-shojib I think this will do the job.

My project we are using Expo with multiple file selection, and by default it was converting the form-data to array with the file reference, something like:

image

I do feel that this will solve the issue.

Thanks for your response

@shahriar-shojib
Copy link
Author

@shahriar-shojib I think this will do the job.

My project we are using Expo with multiple file selection, and by default it was converting the form-data to array with the file reference, something like:

image

I do feel that this will solve the issue.

Thanks for your response

this is indeed what this PR aims to solve!

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

Successfully merging this pull request may close these issues.

3 participants