allow text and application uploads (text, md, html, json, etc)
This commit is contained in:
parent
74fc955f5e
commit
479e77875e
1 changed files with 4 additions and 2 deletions
6
app.py
6
app.py
|
|
@ -76,6 +76,8 @@ if not os.path.exists(DATA_DIR):
|
|||
APP_SECRET_FILE = os.path.join(DATA_DIR, "pyrafiles_secret.txt")
|
||||
JWT_SECRET_FILE = os.path.join(DATA_DIR, "jwt_secret.txt")
|
||||
|
||||
ALLOWED_MIME_PREFIXES = ("image/", "audio/", "video/", "text/", "application/")
|
||||
|
||||
|
||||
def get_or_create_secret(env_var_name, secret_file_path):
|
||||
"""
|
||||
|
|
@ -1176,7 +1178,7 @@ def upload_media_post_view(request):
|
|||
# Determine media type based on MIME type
|
||||
filename = media_file.filename
|
||||
mime_type = get_mime_type(filename)
|
||||
if not mime_type.startswith(("image/", "audio/", "video/")):
|
||||
if not mime_type.startswith(ALLOWED_MIME_PREFIXES):
|
||||
return Response("Unsupported media type.", status=400)
|
||||
|
||||
media_type = mime_type.split("/")[0]
|
||||
|
|
@ -1330,7 +1332,7 @@ def edit_media_post_view(request):
|
|||
file_size = len(raw_bytes)
|
||||
filename = new_media_file.filename
|
||||
mime_type = get_mime_type(filename)
|
||||
if not mime_type.startswith(("image/", "audio/", "video/")):
|
||||
if not mime_type.startswith(ALLOWED_MIME_PREFIXES):
|
||||
return Response("Unsupported media type.", status=400)
|
||||
media_type = mime_type.split("/")[0]
|
||||
encoded_str = base64.b64encode(raw_bytes).decode("utf-8")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue