Example #1
0
def movedir(request):
    path_from = request.POST.get('d', '')
    path_to = request.POST.get('n', '')

    if path_from and path_to:
        shutil.move(safepath(settings.ROXY_ROOT, path_from),
                    safepath(settings.ROXY_ROOT, path_to))

    return ok()
Example #2
0
def renamedir(request):
    path = request.POST.get('d', '')
    new_name = request.POST.get('n')

    if path and new_name:
        shutil.move(
            safepath(settings.ROXY_ROOT, path),
            safepath(settings.ROXY_ROOT, os.path.dirname(path), new_name))

    return ok()
Example #3
0
def copydir(request):
    path_from = request.POST.get('d', '')
    path_to = request.POST.get('n', '')

    if path_from and path_to:
        shutil.copytree(
            safepath(settings.ROXY_ROOT, path_from),
            safepath(settings.ROXY_ROOT, path_to, os.path.basename(path_from)))

    return ok()
Example #4
0
def movedir(request):
    path_from = request.POST.get('d', '')
    path_to = request.POST.get('n', '')

    if path_from and path_to:
        shutil.move(
            safepath(settings.ROXY_ROOT, path_from),
            safepath(settings.ROXY_ROOT, path_to)
        )

    return ok()
Example #5
0
def copydir(request):
    path_from = request.POST.get('d', '')
    path_to = request.POST.get('n', '')

    if path_from and path_to:
        shutil.copytree(
            safepath(settings.ROXY_ROOT, path_from),
            safepath(settings.ROXY_ROOT, path_to, os.path.basename(path_from))
        )

    return ok()
Example #6
0
def renamedir(request):
    path = request.POST.get('d', '')
    new_name = request.POST.get('n')

    if path and new_name:
        shutil.move(
            safepath(settings.ROXY_ROOT, path),
            safepath(settings.ROXY_ROOT, os.path.dirname(path), new_name)
        )

    return ok()
Example #7
0
def deletedir(request):
    path = request.POST.get('d', '')

    if path:
        shutil.rmtree(safepath(settings.ROXY_ROOT, path))

    return ok()
Example #8
0
def deletefile(request):
    path = request.POST.get('f', '')

    if path:
        os.remove(safepath(settings.ROXY_ROOT, path))

    return ok()
Example #9
0
def deletedir(request):
    path = request.POST.get('d', '')

    if path:
        shutil.rmtree(safepath(settings.ROXY_ROOT, path))

    return ok()
Example #10
0
def deletefile(request):
    path = request.POST.get('f', '')

    if path:
        os.remove(safepath(settings.ROXY_ROOT, path))

    return ok()
Example #11
0
def download(request):
    path = request.GET.get('f', '')
    real_path = safepath(settings.ROXY_ROOT, path)
    filename = os.path.basename(real_path)

    response = FileResponse(open(real_path, 'rb'))
    response['Content-Disposition'] = 'attachment; filename=%s' % filename
    return response
Example #12
0
def createdir(request):
    path = request.POST.get('d', '')
    name = request.POST.get('n', '')

    if path and name:
        os.makedirs(safepath(settings.ROXY_ROOT, path, name))

    return ok()
Example #13
0
def createdir(request):
    path = request.POST.get('d', '')
    name = request.POST.get('n', '')

    if path and name:
        os.makedirs(safepath(settings.ROXY_ROOT, path, name))

    return ok()
Example #14
0
def download(request):
    path = request.GET.get('f', '')
    real_path = safepath(settings.ROXY_ROOT, path)
    filename = os.path.basename(real_path)

    with open(real_path) as f:
        response = HttpResponse(f.read(),
                                content_type='application/octet-stream')
    response['Content-Disposition'] = 'attachment; filename=%s' % filename
    return response
Example #15
0
def download(request):
    path = request.GET.get('f', '')
    real_path = safepath(settings.ROXY_ROOT, path)
    filename = os.path.basename(real_path)

    with open(real_path) as f:
        response = HttpResponse(
            f.read(),
            content_type='application/octet-stream'
        )
    response['Content-Disposition'] = 'attachment; filename=%s' % filename
    return response
Example #16
0
def thumb(request):
    path = request.GET.get('f', '')
    width = request.GET.get('w', 100)
    height = request.GET.get('h', 100)

    if path:
        response = HttpResponse(content_type='image/jpeg')
        image = Image.open(safepath(settings.ROXY_ROOT, path)).convert('RGB')
        image.thumbnail((width, height))
        image.save(response, 'JPEG')
        return response

    return err()
Example #17
0
def thumb(request):
    path = request.GET.get('f', '')
    width = request.GET.get('w', 100)
    height = request.GET.get('h', 100)

    if path:
        response = HttpResponse(content_type='image/jpeg')
        image = Image.open(safepath(settings.ROXY_ROOT, path))
        image.thumbnail((width, height))
        image.save(response, 'JPEG')
        return response

    return err()
Example #18
0
def downloaddir(request):
    path = request.GET.get('d', '')
    real_path = safepath(settings.ROXY_ROOT, path)
    dirname = os.path.split(real_path)[-1]

    pid, tmp_file = tempfile.mkstemp()
    filename = shutil.make_archive(os.path.basename(tmp_file), 'zip',
                                   real_path)

    with open(filename, 'rb') as f:
        response = HttpResponse(FileWrapper(f), content_type='application/zip')

    response['Content-Disposition'] = 'attachment; filename=%s.zip' % dirname
    return response
Example #19
0
def downloaddir(request):
    path = request.GET.get('d', '')
    real_path = safepath(settings.ROXY_ROOT, path)
    dirname = os.path.split(real_path)[-1]

    pid, tmp_file = tempfile.mkstemp()
    filename = shutil.make_archive(
        os.path.basename(tmp_file),
        'zip', real_path
    )

    response = FileResponse(open(filename, 'rb'), content_type='application/zip')
    response['Content-Disposition'] = 'attachment; filename=%s.zip' % dirname
    return response