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

[BUG] Not possible to send form-data with duplicate key names #230

Open
jnv opened this issue May 12, 2022 · 0 comments
Open

[BUG] Not possible to send form-data with duplicate key names #230

jnv opened this issue May 12, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@jnv
Copy link
Contributor

jnv commented May 12, 2022

Based on superfaceai/station#242

Mailgun in particular expects email attachments to be submitted under attachment fields in multipart/form-data. However, we don't allow duplicated keys to be sent in body, because it is treated as a JS object.

Possible workaround would be to detect array in value when constructing the FormData object, and append each value individually.

one-sdk-js/src/lib/fetch.ts

Lines 192 to 194 in 1f03560

Object.entries(data).forEach(([key, value]) =>
formData.append(key, value)
);

This makes sense because there isn't any official way to serialize array values in FormData.

Therefore the following Comlink:

body {
  attachment = [bufferA, bufferB]
}

Results in:

attachment=bufferA
attachment=bufferB
@jnv jnv added the bug Something isn't working label May 12, 2022
@freaz freaz self-assigned this Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants