mirror of
https://github.com/jackeilles/xygt.git
synced 2024-11-21 14:22:39 +01:00
okay passing a string through works now, yippee
This commit is contained in:
parent
e582c74363
commit
df987b400d
2 changed files with 14 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
|||
from app import app, worker
|
||||
from config import Config, Errors
|
||||
from flask import render_template, request, send_file
|
||||
from werkzeug.datastructures import FileStorage
|
||||
from io import BytesIO
|
||||
import os
|
||||
import io
|
||||
import random
|
||||
|
@ -41,6 +43,16 @@ def index():
|
|||
|
||||
return result, status
|
||||
|
||||
elif 'file' in request.form:
|
||||
|
||||
file = FileStorage(stream=BytesIO(request.form['file'].encode("utf-8")), filename=id, content_type="text/plain")
|
||||
|
||||
result, status = worker.uploadFile(file, ip, userid, filename, id, retention)
|
||||
|
||||
result = "https://xygt.cc/{}".format(result)
|
||||
|
||||
return result, status
|
||||
|
||||
elif 'url' in request.form:
|
||||
result, status = worker.shortURL(url, ip, userid, id, retention)
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from config import disallowedMimeTypes, Errors, Config
|
||||
from werkzeug.datastructures import FileStorage
|
||||
import secrets
|
||||
import magic
|
||||
import datetime
|
||||
|
@ -32,7 +33,7 @@ def uploadFile(file, ip, userid, filename, id, retention):
|
|||
elif retention > (Config.minretention+(-Config.maxretention + Config.minretention)*pow((fileSize / Config.maxFileSize -1), 3)):
|
||||
retention = (Config.minretention+(-Config.maxretention + Config.minretention)*pow((fileSize / Config.maxFileSize -1), 3))
|
||||
|
||||
if file.
|
||||
|
||||
# Create the file
|
||||
with open(f"{os.path.abspath(Config.fileDir)}/{filename}", "wb") as f:
|
||||
f.write(file.read())
|
||||
|
|
Loading…
Reference in a new issue