import os

from sorl.thumbnail import get_thumbnail

from ajaxuploader.backends.local import LocalUploadBackend

class ThumbnailUploadBackend(LocalUploadBackend):
    def __init__(self, dimension):
        self._dimension = dimension
    
    def upload_complete(self, request, filename):
        thumbnail = get_thumbnail(self._filename, self._dimension)
        os.unlink(self._filename)
        return {"path": thumbnail.name}

import os

from django.conf import settings
from sorl.thumbnail import get_thumbnail

from ajaxuploader.backends.local import LocalUploadBackend

class ThumbnailUploadBackend(LocalUploadBackend):
    DIMENSION = "100x100"

    def upload_complete(self, request, filename):
        thumbnail = get_thumbnail(self._path, self.DIMENSION)
        os.unlink(self._path)
        return {"path": settings.MEDIA_URL + thumbnail.name}

Use dimension as a constant, so we keep same interface for all backends; also returns full path to the place where image was saved
Use dimension as a constant, so we keep same interface for all backends; also returns full path to the place where image was saved

  import os
  
+ from django.conf import settings
  from sorl.thumbnail import get_thumbnail
  
  from ajaxuploader.backends.local import LocalUploadBackend
  
  class ThumbnailUploadBackend(LocalUploadBackend):
+     DIMENSION = "100x100"
+ 
-     def __init__(self, dimension):
-         self._dimension = dimension
-     
      def upload_complete(self, request, filename):
-         thumbnail = get_thumbnail(self._filename, self._dimension)
+         thumbnail = get_thumbnail(self._path, self.DIMENSION)
-         os.unlink(self._filename)
+         os.unlink(self._path)
-         return {"path": thumbnail.name}
+         return {"path": settings.MEDIA_URL + thumbnail.name}
  
Use dimension as a constant, so we keep same interface for all backends; also returns full path to the place where image was saved
## Code Before:
import os

from sorl.thumbnail import get_thumbnail

from ajaxuploader.backends.local import LocalUploadBackend

class ThumbnailUploadBackend(LocalUploadBackend):
    def __init__(self, dimension):
        self._dimension = dimension
    
    def upload_complete(self, request, filename):
        thumbnail = get_thumbnail(self._filename, self._dimension)
        os.unlink(self._filename)
        return {"path": thumbnail.name}

## Instruction:
Use dimension as a constant, so we keep same interface for all backends; also returns full path to the place where image was saved
## Code After:
import os

from django.conf import settings
from sorl.thumbnail import get_thumbnail

from ajaxuploader.backends.local import LocalUploadBackend

class ThumbnailUploadBackend(LocalUploadBackend):
    DIMENSION = "100x100"

    def upload_complete(self, request, filename):
        thumbnail = get_thumbnail(self._path, self.DIMENSION)
        os.unlink(self._path)
        return {"path": settings.MEDIA_URL + thumbnail.name}
