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()
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()
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()
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()
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()
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()
def deletedir(request): path = request.POST.get('d', '') if path: shutil.rmtree(safepath(settings.ROXY_ROOT, path)) return ok()
def deletefile(request): path = request.POST.get('f', '') if path: os.remove(safepath(settings.ROXY_ROOT, path)) return ok()
def deletedir(request): path = request.POST.get('d', '') if path: shutil.rmtree(safepath(settings.ROXY_ROOT, path)) return ok()
def deletefile(request): path = request.POST.get('f', '') if path: os.remove(safepath(settings.ROXY_ROOT, path)) return ok()
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
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()
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()
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
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
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()
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()
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
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