Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

bug: wrong spec for multiple files upload #361

Closed
giautm opened this issue Feb 24, 2021 · 2 comments
Closed

bug: wrong spec for multiple files upload #361

giautm opened this issue Feb 24, 2021 · 2 comments
Labels
1️⃣ good first issue Good for newcomers 🐛 bug Something isn't working 📱 client 🏃 relay Related react relay

Comments

@giautm
Copy link
Contributor

giautm commented Feb 24, 2021

https://github.com/dooboolab/hackatalk/blob/3284e8b997f61408e5eda45254f52d3f6a48e8df/client/src/relay/fetch.ts#L54

From spec: https://github.com/jaydenseric/graphql-multipart-request-spec#curl-request-1, map should be valid JSON

{ "0": ["variables.files.0"], "1": ["variables.files.1"] }

But, the result from that line is

{ "0": ["variables.files.0"] }{ "1": ["variables.files.1"] }
@giautm
Copy link
Contributor Author

giautm commented Feb 24, 2021

    const map: { [key: number]: string[] } = {}

    if (uploadables.file) {
      // single upload
      map[0] = ['variables.file']
      formData.append('0', uploadables.file)
    } else {
      // multi uploads
      for (const i in uploadables.files) {
        map[i] = [`variables.files.${i}`]
        formData.append(i, uploadables.files[i])
      }
    }
    formData.append('map', JSON.stringify(map))

    config.body = formData

@hyochan
Copy link
Owner

hyochan commented Feb 28, 2021

@giautm Thanks for the great fixes! Could you kindly open a PR for this? I think we should change the multi upload part.

@hyochan hyochan added 1️⃣ good first issue Good for newcomers 🏃 relay Related react relay 📱 client 🐛 bug Something isn't working labels Feb 28, 2021
giautm added a commit to giautm/hackatalk that referenced this issue Mar 1, 2021
hyochan pushed a commit to giautm/hackatalk that referenced this issue Mar 2, 2021
@hyochan hyochan closed this as completed in 954fef9 Mar 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1️⃣ good first issue Good for newcomers 🐛 bug Something isn't working 📱 client 🏃 relay Related react relay
Projects
None yet
Development

No branches or pull requests

2 participants