def process_upload(self): # save the file w/ soil self.uploaded_file.file.seek(0) saved_file = expose_download(self.uploaded_file.file.read(), expiry=BulkMultimediaStatusCache.cache_expiry) processing_id = saved_file.download_id status = BulkMultimediaStatusCache(processing_id) status.save() process_bulk_upload_zip.delay(processing_id, self.domain, self.app_id, username=self.request.couch_user.username if self.request.couch_user else None, share_media=self.share_media, license_name=self.license_used, author=self.author, attribution_notes=self.attribution_notes, replace_existing=self.replace_existing) return status.get_response()
def post(self, request, *args, **kwargs): if not self.processing_id: return HttpResponseBadRequest("A processing_id is required.") status = BulkMultimediaStatusCache.get(self.processing_id) if status is None: # No status could be retrieved from the cache fake_status = BulkMultimediaStatusCache(self.processing_id) fake_status.complete = True fake_status.errors.append(_('There was an issue retrieving the status from the cache. ' 'We are looking into it. Please try uploading again.')) logging.error("[Multimedia Bulk Upload] Process ID #%s encountered an issue while retrieving " "a status from the cache." % self.processing_id) response = fake_status.get_response() else: response = status.get_response() return HttpResponse(json.dumps(response))
def process_upload(self): # save the file w/ soil self.uploaded_file.file.seek(0) saved_file = expose_download(self.uploaded_file.file.read(), expiry=BulkMultimediaStatusCache.cache_expiry) processing_id = saved_file.download_id status = BulkMultimediaStatusCache(processing_id) status.save() process_bulk_upload_zip.delay(processing_id, self.domain, self.app_id, username=self.username, share_media=self.share_media, license_name=self.license_used, author=self.author, attribution_notes=self.attribution_notes, replace_existing=self.replace_existing) return status.get_response()