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

Uploading array of files #586

Closed
oguzbilgic opened this issue Nov 11, 2015 · 5 comments
Closed

Uploading array of files #586

oguzbilgic opened this issue Nov 11, 2015 · 5 comments

Comments

@oguzbilgic
Copy link

Is there a way to upload array of files?

getFiles(): ?FileMap

// Type of the FileMap object
type FileMap = {[key: string]: File};

Would it make sense to improve FileMap type to something like this:

type FileMap = {[key: string]: File | [File]};
@devknoll
Copy link
Contributor

@oguzbilgic Neat idea. Would you mind opening a PR?

You could work around this today by passing in an array to your mutations constructor and mapping each file to a unique key in getFiles, but it seems useful to be able to take advantage of the built-in support for arrays in the browser and web servers.

@wincent
Copy link
Contributor

wincent commented Feb 8, 2016

Thanks for filing this issue @oguzbilgic!

This is important, so I'm going to fold it into #538, which is about overhauling the mutations API. (It will be easier to manage with the various interrelated mutations issues in a single place.)

@eugenehp
Copy link

@oguzbilgic were you able to find a solution for this?

@chrise86
Copy link

chrise86 commented Aug 9, 2016

@oguzbilgic also interested to hear if you found a solution 👍

nossila added a commit to nossila/relay that referenced this issue Oct 27, 2016
A suggestion was made on facebook#586 but I thought using FileList instead of [File] was a better idea since I would not need to loop through the FileList (since its what is provided the HTML file input's API) to construct an array of files every time I need to send multiple files to a Mutation, this way Relay will handle it for me, I just need to send FileList or File object.
@sibelius
Copy link
Contributor

I think a file map makes more sense, should use the filename in the key and disregard it on server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants