def handle_chunk(self): f = ContentFile(self.request.raw_post_data) if "upload-uuid" in self.request.session: try: u = Upload.objects.get(uuid=self.request.session["upload-uuid"]) if u.state in [Upload.STATE_COMPLETE, Upload.STATE_UPLOAD_ERROR]: del self.request.session["upload-uuid"] except Upload.DoesNotExist: del self.request.session["upload-uuid"] if "upload-uuid" not in self.request.session: u = Upload.objects.create( user=self.request.user, filename=self.request.META["HTTP_X_FILE_NAME"], filesize=self.request.META["HTTP_X_FILE_SIZE"] ) self.request.session["upload-uuid"] = str(u.uuid) c = Chunk(upload=u) c.chunk.save(u.filename, f, save=False) c.chunk_size = c.chunk.size c.save() data = [] data.append(self._add_status_response(u)) return HttpResponse(json.dumps(data), mimetype="application/json")
def handle_chunk(self): f = ContentFile(self.request.raw_post_data) if "upload-uuid" in self.request.session: try: u = Upload.objects.get( uuid=self.request.session["upload-uuid"]) if u.state in [ Upload.STATE_COMPLETE, Upload.STATE_UPLOAD_ERROR ]: del self.request.session["upload-uuid"] except Upload.DoesNotExist: del self.request.session["upload-uuid"] if "upload-uuid" not in self.request.session: u = Upload.objects.create( user=self.request.user, filename=self.request.META["HTTP_X_FILE_NAME"], filesize=self.request.META["HTTP_X_FILE_SIZE"]) self.request.session["upload-uuid"] = str(u.uuid) c = Chunk(upload=u) c.chunk.save(u.filename, f, save=False) c.chunk_size = c.chunk.size c.save() data = [] data.append(self._add_status_response(u)) return HttpResponse(json.dumps(data), mimetype="application/json")
def handle_chunk(self): f = ContentFile(self.request.body) if "upload-uuid" in self.request.session: try: u = Upload.objects.get( uuid=self.request.session["upload-uuid"]) if u.state == Upload.STATE_COMPLETE: del self.request.session["upload-uuid"] except Upload.DoesNotExist: del self.request.session["upload-uuid"] if "upload-uuid" not in self.request.session: content_disposition = self.request.META["HTTP_CONTENT_DISPOSITION"] try: content_range = self.request.META["HTTP_CONTENT_RANGE"] content_range = content_range.split("/")[1] except: content_range = self.request.META["CONTENT_LENGTH"] u = Upload.objects.create( user=self.request.user, filename=sanitize_filename( unicode(content_disposition.split("=")[1].split('"')[1])), filesize=content_range) self.request.session["upload-uuid"] = str(u.uuid) c = Chunk(upload=u) c.chunk.save(u.filename, f, save=False) c.chunk_size = c.chunk.size c.save() data = [] data.append(self._add_status_response(u)) return data
def handle_chunk(self): f = ContentFile(self.request.raw_post_data) if "upload-uuid" in self.request.session: try: u = Upload.objects.get(uuid=self.request.session["upload-uuid"]) if u.state in [Upload.STATE_COMPLETE, Upload.STATE_UPLOAD_ERROR]: del self.request.session["upload-uuid"] except Upload.DoesNotExist: del self.request.session["upload-uuid"] if "upload-uuid" not in self.request.session: content_disposition = self.request.META["HTTP_CONTENT_DISPOSITION"] logging.debug(sanitize_filename(unicode(content_disposition.split("=")[1].split('"')[1]))) content_range = self.request.META["HTTP_CONTENT_RANGE"] u = Upload.objects.create( user=self.request.user, filename=sanitize_filename(unicode(content_disposition.split("=")[1].split('"')[1])), filesize=content_range.split("/")[1] ) self.request.session["upload-uuid"] = str(u.uuid) c = Chunk(upload=u) c.chunk.save(u.filename, f, save=False) c.chunk_size = c.chunk.size c.save() data = [] data.append(self._add_status_response(u)) return HttpResponse(json.dumps(data), mimetype="application/json")
def handle_chunk(self): f = ContentFile(self.request.raw_post_data) if "upload-uuid" in self.request.session: try: u = Upload.objects.get(uuid=self.request.session["upload-uuid"]) if u.state==Upload.STATE_COMPLETE: del self.request.session["upload-uuid"] except Upload.DoesNotExist: del self.request.session["upload-uuid"] if "upload-uuid" not in self.request.session: content_disposition = self.request.META["HTTP_CONTENT_DISPOSITION"] try: content_range = self.request.META["HTTP_CONTENT_RANGE"] content_range = content_range.split("/")[1] except: content_range = self.request.META["CONTENT_LENGTH"] u = Upload.objects.create( user=self.request.user, filename=sanitize_filename(unicode(content_disposition.split("=")[1].split('"')[1])), filesize=content_range ) self.request.session["upload-uuid"] = str(u.uuid) c = Chunk(upload=u) c.chunk.save(u.filename, f, save=False) c.chunk_size = c.chunk.size c.save() data = [] data.append(self._add_status_response(u)) return data