Multipart file upload in v 0.5+


#1

Back in 0.3.9 we had the apistar.parsers.MultiPartParser which we could use for file uploads. I am a little in the dark now as to how to accept file uploads in the 0.5+ versions. Can anyone help?


#2

I don’t know if this component still works but used to in 0.3.9.


FormFiles = Dict[str, FileStorage]


def get_file_array(request_data: http.RequestData) -> FormFiles:
    return {
        name: file_storage
        for name, file_storage in request_data.items()
        if isinstance(file_storage, FileStorage)
    }

component = Component(FormFiles, init=get_file_array)

#3

Is FileStorage in this case the werzeug.datastructures.FileStorage?


#4

Yes, was it. Hope that still is.


#5

Ok, finally had time to look at this. I went back to the 0.3.9 implementation and just updated it for APIStar >= 0.4.