Skip to content

how to upload file with graphene-file-upload #1170

Answered by kevinzDzul
kevinzDzul asked this question in Q&A
Discussion options

You must be logged in to vote

my mutation,
filedata[0] is array for multiple files

class UploadFileMtrs(graphene.Mutation):

class Input:
    filedata = Upload()

filedata = Upload
nameFile = graphene.String()


@staticmethod
def mutate(self, info,  filedata=None):
    print(filedata[0])

    date_file = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    date = datetime.datetime.now().strftime("%Y-%m-%d_%H:%M:%S")
    dateplus = date + ".txt"
    fs = FileSystemStorage()
    fs.save(dateplus,filedata[0])

use this library in back: https://github.com/lmcgartland/graphene-file-upload
and use this in frond : https://github.com/jaydenseric/apollo-upload-client

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by zbyte64
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #582 on April 14, 2021 20:08.