Exemple #1
0
    def setUp(self):
        test_storage = FileSystemStorage(
            location=getattr(settings, 'FILE_UPLOAD_TEMP_DIR'))
        fixtures_storage = FileSystemStorage(location=CHUNKS_ROOT)

        for filename in fixtures_storage.listdir('.')[1]:
            test_storage.save(filename, fixtures_storage.open(filename))
        self.seagull = ResumableFile(test_storage, seagull)
        self.craw = ResumableFile(test_storage, craw)
        self.storage = test_storage
Exemple #2
0
 def get(self, *args, **kwargs):
     """Checks if chunk has allready been sended.
     """
     r = ResumableFile(self.storage, self.request.GET)
     if not (r.chunk_exists or r.is_complete):
         return HttpResponse('chunk not found', status=404)
     if r.is_complete:
         message=self.process_file(r.filename, r.file)
         r.delete_chunks()
         return HttpResponse(message)
     return HttpResponse('chunk already exists')
Exemple #3
0
 def get(self, *args, **kwargs):
     """Checks if chunk has allready been sended.
     """
     r = ResumableFile(self.storage, self.request.GET)
     if not (r.chunk_exists or r.is_complete):
         return HttpResponse('chunk not found', status=404)
     return HttpResponse('chunk already exists')
Exemple #4
0
    def post(self, *args, **kwargs):
        """Saves chunks then checks if the file is complete."""

        message=""


        uploader = self.request.POST.get('uploader',None)
        if uploader == 'plupload':
            message = self.handle_plupload_post(*args, **kwargs)
        else:
            chunk = self.request.FILES.get('file')
            r = ResumableFile(self.storage, self.request.POST)
            if r.chunk_exists:
                if r.is_complete:
                    message = self.process_file(r.filename, r.file)
                    r.delete_chunks()
                    return HttpResponse(message)
                else:
                    return HttpResponse('chunk already exists new')
            r.process_chunk(chunk)


            if r.is_complete:
                message = self.process_file(r.filename, r.file)
                r.delete_chunks()
        return HttpResponse(message)
Exemple #5
0
 def post(self, *args, **kwargs):
     """Saves chunks then checks if the file is complete.
     """
     chunk = self.request.FILES.get('file')
     r = ResumableFile(self.storage, self.request.POST)
     if r.chunk_exists:
         return HttpResponse('chunk already exists')
     r.process_chunk(chunk)
     if r.is_complete:
         self.process_file(r.filename, r.file)
         r.delete_chunks()
     return HttpResponse()
Exemple #6
0
    def post(self, *args, **kwargs):
        """Saves chunks then checks if the file is complete.
        """
        chunk = self.request.FILES.get('file')
        r = ResumableFile(self.storage, self.request.POST)
        if r.chunk_exists:
            return HttpResponse('chunk already exists')
        r.process_chunk(chunk)
        if r.is_complete:
            resource = Resource.objects.get(id=kwargs["resource_id"])
            self.process_file(r.filename, r, resource)
            r.delete_chunks()

            return HttpResponseRedirect(resource.get_absolute_url())
        return HttpResponse()
Exemple #7
0
    def get(self, request, *args, **kwargs):

        if "resumableChunkNumber" in request.GET:
            r = ResumableFile(self.storage, self.request.GET)
            if not (r.chunk_exists or r.is_complete):
                return HttpResponse('chunk not found', status=404)
            return HttpResponse('chunk already exists')
        else:
            resource = Resource.objects.get(id=kwargs["resource_id"])
            bdb = Biodatabase.objects.filter(name=resource.name)
            loaded = bool(bdb.count())
            if loaded:
                return HttpResponseRedirect(resource.get_absolute_url())

            form = ResumableForm()
            return render(
                request, self.template_name, {
                    "resource": resource,
                    'form': form,
                    "resource_id": kwargs["resource_id"]
                })