FileUploader object provides basic functionality to work with files uploaded with wsgikit.HttpRequest object
Naturally there is no need to instantiate it as far as it is instantiated automatically by HttpRequest during the HTTP request processing.
It is enough to use it as:
import wsgikit
def my_wsgi_app( environ, start_response):
status = '200 OK'
response_headers = [('Content-type','text/plain')]
start_response( status, response_headers)
request = wsgikit.HttpRequest( environ)
if request.has_files():
try :
request.FileUploader.move_all(
destination = '/my/cool/file/storage',
overwrite = True
)
my_response = 'Thank you, we saved all you pass!'
except FileUploaderError as e:
my_response = "Oops, we can't save this! Reason: %s" %e
else :
my_response = 'There is nothing to do, sorry...'
return my_response
Moves a single uploaded file from a temporary location to the given destination. If overwrite is turned on file will be overwritten during the move, otherwise error will be raised
Parameters: |
|
---|---|
Return type: | returns new file destination on success |
Raise : | FileOverwriteError, UploadedFileSaveError or MoveError |
Moves all the files uploaded during HTTP request to the given destination
Parameters: |
|
---|---|
Return type: | list - new files destinations |
Raise : | FileOverwriteError, UploadedFileSaveError, MoveDestinationError or MoveError |