Beispiel #1
0
def download_post():

    context = {}
    context["file"] = FileService().get_object_or_404(url=request.args.get("h"))
    context["file_size"] = FileService().get_size(context["file"])

    return render_template("file/download.html", **context)
Beispiel #2
0
def make_public():

    db_file = FileService().get_one(id=request.form.get("id"), user=g.user)
    db_file.is_public = request.form.get("is_public") == str(True).lower()

    FileService().save(db_file)

    return "ok"
Beispiel #3
0
def delete():

    db_file = FileService().get_one(user=g.user, id=request.form.get("id"))

    if not FileService().delete(db_file):
        return "fail"

    return "ok"
Beispiel #4
0
def download():

    db_file = FileService().get_object_or_404(url=request.args.get("h"))
    content = FileService().get_content(db_file)

    response = make_response(content)
    response.headers["Content-Disposition"] = "attachment; filename={0}".format(db_file.name)
    return response
Beispiel #5
0
def search():

    context = {}
    file_name = request.form.get("name")
    context["files"] = FileService().search(g.user, file_name)

    return render_template("file/search.html", **context)
Beispiel #6
0
def list():

    context = {}
    context["files"] = FileService().filter_by(user=g.user)

    return render_template("file/list.html", **context)
Beispiel #7
0
def upload_post():

    return FileService().save_file(request, g.user)