author: Sylvain Viollon
date: Mon Jul 29 16:13:51 2013 +0200
revision: 6:5f05d7418d80 in infrae.fileupload
branch:
details: https://hg.infrae.com/infrae.fileupload?cmd=changeset;node=5f05d7418d80
modified: src/infrae/fileupload/upload.py
added:
removed:
log: Implement a clear.
diffstat:
src/infrae/fileupload/upload.py | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diffs (40 lines):
diff -r 35e5fb68d74f -r 5f05d7418d80 src/infrae/fileupload/upload.py
--- a/src/infrae/fileupload/upload.py Mon Jul 29 15:35:11 2013 +0200
+++ b/src/infrae/fileupload/upload.py Mon Jul 29 16:13:51 2013 +0200
@@ -113,7 +113,7 @@
return self._data
return None
- def clean(self):
+ def clear(self):
# This is called by the middleware if the upload fails.
self._api.clear_upload_bucket(self._identifier)
@@ -251,6 +251,8 @@
else:
if 'status' in request.GET:
application = self.status(request, identifier)
+ elif 'clear' in request.GET:
+ application = self.status(request, identifier)
elif (request.method == 'POST' and
request.content_type == 'multipart/form-data'):
application = self.upload(request, identifier)
@@ -336,6 +338,18 @@
request.content_length = len(info)
return request.get_response(self.application)
+ def clear(self, request, identifier):
+ """Request an upload. This is called before starting the
+ upload. To be sure the file is missing.
+ """
+ upload = self.manager.access_upload_bucket(identifier)
+ if upload is not None:
+ upload.clear()
+ response = Response()
+ response.content_type = 'application/json'
+ response.body = '{success: true}'
+ return response
+
def status(self, request, identifier):
"""Handle status information on the upload process of a file.
"""
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.