Compare commits
No commits in common. "b772ce8b7e79cfbf1b2558fb665ded298e5a1359" and "600edca8cd00fdedb98db26f3ff227ed454e9aa5" have entirely different histories.
b772ce8b7e
...
600edca8cd
BIN
dist/rupload-1.3.37-py3-none-any.whl
vendored
BIN
dist/rupload-1.3.37-py3-none-any.whl
vendored
Binary file not shown.
BIN
dist/rupload-1.3.37.tar.gz
vendored
BIN
dist/rupload-1.3.37.tar.gz
vendored
Binary file not shown.
@ -1,20 +1,16 @@
|
|||||||
import pathlib
|
import aiohttp
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
import asyncio
|
||||||
MAX_FILE_SIZE = 1024 * 1024 * 50 # 50Mb
|
import pathlib
|
||||||
UPLOAD_FOLDER_QUOTA = 10 * 1024 * 1024 * 1024 # 10Gb
|
|
||||||
UPLOAD_URL = "/"
|
|
||||||
UPLOAD_PATH = "uploads"
|
|
||||||
|
|
||||||
|
|
||||||
class Rupload(web.Application):
|
class Rupload(web.Application):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
upload_url: str = UPLOAD_URL,
|
upload_url: str = "/uploads/",
|
||||||
upload_path: str = UPLOAD_PATH,
|
upload_path: str = "uploads",
|
||||||
max_file_size: int = MAX_FILE_SIZE,
|
max_file_size: int = 1024 * 1024 * 50,
|
||||||
upload_folder_quota: int = UPLOAD_FOLDER_QUOTA,
|
upload_folder_quota: int = 10 * 1024 * 1024 * 1024,
|
||||||
):
|
):
|
||||||
self.upload_path = upload_path.rstrip("/")
|
self.upload_path = upload_path.rstrip("/")
|
||||||
self.max_file_size = max_file_size
|
self.max_file_size = max_file_size
|
||||||
@ -180,8 +176,6 @@ def get_images(path):
|
|||||||
".gif",
|
".gif",
|
||||||
".jpeg",
|
".jpeg",
|
||||||
".bmp",
|
".bmp",
|
||||||
".webp",
|
|
||||||
".svg",
|
|
||||||
]:
|
]:
|
||||||
images.append(image)
|
images.append(image)
|
||||||
return images
|
return images
|
||||||
@ -253,7 +247,9 @@ async def handle_upload(request: web.Request):
|
|||||||
print(f"File {filename} deleted.")
|
print(f"File {filename} deleted.")
|
||||||
return web.Response(
|
return web.Response(
|
||||||
status=413,
|
status=413,
|
||||||
text=f"File is too large. Maximum file size is {app.max_file_size} bytes.",
|
text="File is too large. Maximum file size is {} bytes.".format(
|
||||||
|
app.max_file_size
|
||||||
|
),
|
||||||
)
|
)
|
||||||
f.write(chunk)
|
f.write(chunk)
|
||||||
print(f"File {filename} uploaded successfully.")
|
print(f"File {filename} uploaded successfully.")
|
||||||
@ -285,9 +281,7 @@ async def handle_index(request: web.Request):
|
|||||||
message += f'<a href="{url}">'
|
message += f'<a href="{url}">'
|
||||||
message += f"{url}</a>"
|
message += f"{url}</a>"
|
||||||
if not message:
|
if not message:
|
||||||
message = (
|
message = "Any file type is allowed thus also binary/executable or source files."
|
||||||
"Any file type is allowed thus also binary/executable or source files."
|
|
||||||
)
|
|
||||||
if message:
|
if message:
|
||||||
message += "<br /><br />"
|
message += "<br /><br />"
|
||||||
html_content = html_content.replace("[message]", message)
|
html_content = html_content.replace("[message]", message)
|
||||||
@ -295,10 +289,10 @@ async def handle_index(request: web.Request):
|
|||||||
|
|
||||||
|
|
||||||
def create_app(
|
def create_app(
|
||||||
upload_url: str = UPLOAD_URL,
|
upload_url: str = "/",
|
||||||
upload_path: str = UPLOAD_PATH,
|
upload_path: str = "upload",
|
||||||
max_file_size: int = MAX_FILE_SIZE,
|
max_file_size: int = 1024 * 1024 * 50,
|
||||||
upload_folder_quota: int = UPLOAD_FOLDER_QUOTA,
|
upload_folder_quota: int = 10 * 1024 * 1024 * 1024,
|
||||||
):
|
):
|
||||||
app = Rupload(
|
app = Rupload(
|
||||||
upload_url=upload_url,
|
upload_url=upload_url,
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
|
||||||
from rupload.app import create_app
|
from rupload.app import create_app
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user