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] Multipart file with extra named fields fails to merge properly #489

Open
antonioparisi opened this issue May 27, 2024 · 0 comments
Open

Comments

@antonioparisi
Copy link

antonioparisi commented May 27, 2024

Hi there,

I was playing around to get the current example working, I kind of managed to, but whenever you need to send params named like the following example:

    {:multipart, [
      {"workspace[c_id]", "..."},
      {"workspace[namespace_uuid]", "..."},
      {"workspace[name]", "workspace name"},
      {"workspace[demo]", "false"},
      {:file, logo_file_path(), {"form-data", [name: "workspace[logo]", filename: Path.basename(logo_file_path())]}, []},
    ]}

what will get sent is the following:

{"workspace"=>{"filename"=>"logo.png", "type"=>"image/png", "name"=>"workspace", "tempfile"=>#<Tempfile:/var/folders/j9/wb2bylys5nqcv4djbdbbvsy40000gn/T/RackMultipart20240528-25837-93ahy6.png>, "head"=>"content-length: 9287\r\ncontent-type: image/png\r\ncontent-disposition: form-data; name=workspace[logo]; filename=logo.png\r\n"}}

now, the expected results ideally would have had also the other attributes under the workspace[] but they got lost apparently.

instead on this other example:

    {:multipart, [
      {"workspace[c_id]", "..."},
      {"workspace[namespace_uuid]", "..."},
      {"workspace[name]", "workspace name"},
      {"workspace[demo]", "false"},
      {:file, logo_file_path(), {"form-data", [name: "logo", filename: Path.basename(logo_file_path())]}, []},
    ]}

what will get sent is the following:

{"workspace"=>{"c_id"=>"...", "namespace_uuid"=>"....", "name"=>"workspace name", "demo"=>"false"}, "logo"=>{"filename"=>"logo.png", "type"=>"image/png", "name"=>"logo", "tempfile"=>#<Tempfile:/var/folders/j9/wb2bylys5nqcv4djbdbbvsy40000gn/T/RackMultipart20240528-25837-x6l46o.png>, "head"=>"content-length: 9287\r\ncontent-type: image/png\r\ncontent-disposition: form-data; name=logo; filename=logo.png\r\n"}}

which is correct.
so the issue is only on the first scenario

any hint would be grateful

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

1 participant