I am working on a SDK that validates and saves incoming multipart/form-data files to disk on the server side. Something like:
sdk.upload(httpRequest, destinationPath, validationOptions)
I need the incoming http request for: field name, file name, file and mime type.
The problem is that python frameworks have different http request objects:
request.FILES contains the filesrequest.files contains the files.request.POST contains the files.Same for a file value object from files dictionary, which has different structures.
What I need is a unified/generic http request object or another solution to handle that in one way.
Possible inconvenient solutions:
Examples in other languages:
All frameworks implement WSGI protocol https://www.python.org/dev/peps/pep-0333/ . It's the common underlying mechanism and they have built their own convenience functions on the top of that. You can always go back to raw WSGI.
After upload has been processes there is a common framework to store and process the file: Depot http://depot.readthedocs.io/en/latest/
For example you can grab raw WSGI data and generate WebOb Request object out of it in every framework http://webob.org/
Also see Authomatic for inspirations http://peterhudec.github.io/authomatic/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With