def METHOD_NAME(request):
    response = {}
    response["errormsg"] = {}
    if (
        "image" in request.FILES
        and request.FILES["image"].content_type not in ALLOWED_FILETYPES
    ):
        status = 200  # Not implemented
        response["errormsg"]["error"] = _("Filetype not supported")
    elif (
        settings.MEDIA_MAX_SIZE
        and "image" in request.FILES
        and request.FILES["image"].size > settings.MEDIA_MAX_SIZE
    ):
        status = 413
        response["errormsg"]["error"] = _("Image too large")
    else:
        image = False
        if "id" in request.POST and "image" not in request.FILES:
            user_image = UserImage.objects.filter(
                image_id=int(request.POST["id"]), owner=request.user
            ).first()
            if user_image:
                image = user_image.image
                status = 200
        if image is False:
            image = Image()
            image.uploader = request.user
            user_image = UserImage()
            user_image.owner = request.user
            status = 201
            if "checksum" in request.POST:
                image.checksum = request.POST["checksum"]
        user_image.title = request.POST["title"]
        if "copyright" in request.POST:
            user_image.copyright = json.loads(request.POST["copyright"])
        if "cats" in request.POST:
            user_image.cats = json.loads(request.POST["cats"])
        if "image" in request.FILES:
            image.image = request.FILES["image"]
        if status == 201 and "image" not in request.FILES:
            status = 200
            response["errormsg"]["error"] = _("No file uploaded")
        else:
            image.METHOD_NAME()
            user_image.image = image
            user_image.METHOD_NAME()
            response["values"] = {
                "id": image.id,
                "title": user_image.title,
                "copyright": user_image.copyright,
                "image": image.image.url,
                "file_type": image.file_type,
                "added": mktime(image.added.timetuple()) * 1000,
                "checksum": image.checksum,
                "cats": user_image.cats,
            }
            if image.thumbnail:
                response["values"]["thumbnail"] = image.thumbnail.url
                response["values"]["height"] = image.height
                response["values"]["width"] = image.width
    return JsonResponse(response, status=status)