dooboolab-community/hackatalk

bug: wrong spec for multiple files upload

giautm opened this issue · 2 comments

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"] }
    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

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