def delete_file(request):
    src = request.POST.get('src')
    try:
        File.delete(src)
        return Response(json.dumps('ok'))
    except:
        raise Exception('Could not delete file')
예제 #2
0
def delete_file(request):
    src = request.POST.get('src', '')
    try:
      File.delete(src)
      return HttpResponse('ok', content_type="application/json")
    except:
      raise Exception('Could not delete file')
예제 #3
0
def delete_file():
    src = request.form.get('src')
    try:
      File.delete(src)
      return json.dumps('ok')
    except:
      raise Exception('Could not delete file')
def upload_file(request):
    options = {'validation': None}
    try:
        response = File.upload(PyramidAdapter(request), '/public/', options)
    except Exception:
        response = {'error': str(sys.exc_info()[1])}
    return Response(json.dumps(response))
def upload_file(request):
    options = {'validation': None}
    try:
        response = File.upload(DjangoAdapter(request), '/public/', options)
    except Exception:
        response = {'error': str(sys.exc_info()[1])}
    return HttpResponse(json.dumps(response), content_type="application/json")
 def delete(src):
     """
     Delete video from disk.
     Parameters:
         src: string
     """
     return File.delete(src)
def upload_file_validation(request):
    def validation(filePath, mimetype):
        size = os.path.getsize(filePath)
        if size > 10 * 1024 * 1024:
            return False
        return True

    options = {'fieldname': 'myFile', 'validation': validation}
    try:
        response = File.upload(PyramidAdapter(request), '/public/', options)
    except Exception:
        response = {'error': str(sys.exc_info()[1])}
    return Response(json.dumps(response))