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

how to use dropzonejs upload image in front page? #1895

Closed
bookyo opened this issue Nov 2, 2019 · 1 comment
Closed

how to use dropzonejs upload image in front page? #1895

bookyo opened this issue Nov 2, 2019 · 1 comment

Comments

@bookyo
Copy link

bookyo commented Nov 2, 2019

how to use dropzonejs upload image in front page?

type File {
id: ID
path: String
filename: String
originalFilename: String
mimetype: String
encoding: String
publicUrl: String
}

i dont know how to use graphql upload file to server.

@MadeByMike
Copy link
Contributor

Hi @bookyo, This one is not really a Keystone question... except maybe the part about the graphQL API. Anyway let me try and give you some general direction. But because this question not to specific you will have to fill in the gaps:

  • First make sure you have set-up the file adapter correctly. Test and make sure it's working in the adminUI. It should look something like this (assuming a local file adapter):

Adapter Config:

const fileAdapter = new LocalFileAdapter({
  src: `uploads`,
  path: `/uploads`
});

Field config:

file: {
  type: File,
  adapter: fileAdapter
},
  • Check out the graphQL explorer to test out the mutation you need to write. The default URL for this is: /admin/graphiql

A mutation for create looks something like this:

mutation {
  createYourListName(data: { file: FILE_OBJECT }) {
    id
  }
}

With dropzone you should be able to get a file object: https://developer.mozilla.org/en-US/docs/Web/API/File and upload this via graphQL.

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

2 participants