strawberry icon indicating copy to clipboard operation
strawberry copied to clipboard

Getting the file name and type when uploading

Open offbrok opened this issue 2 years ago • 1 comments

Framework: sanic Is there any way to get the name and type of the uploaded file? We are currently using this implementation:

for _, file_list in info.context.req.files.items():
    file_name = file_list[0].name
    file_size = len(file_list[0].body)
    file_type = file_list[0].type

Is there a more correct way to get this data using the Upload scalar?

offbrok avatar Apr 26 '22 15:04 offbrok

@offbrok yes, unfortunately the current implementation of Upload returns a BytesIO object for Sanic:

image

we might want to change that

patrick91 avatar Apr 26 '22 15:04 patrick91