mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
2ab472fad4
commit
7bd8d630e0
|
@ -256,7 +256,7 @@ from utils import valid_password
|
||||||
from utils import remove_line_endings
|
from utils import remove_line_endings
|
||||||
from utils import get_base_content_from_post
|
from utils import get_base_content_from_post
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import getImageExtensionFromMimeType
|
from utils import get_image_extension_from_mime_type
|
||||||
from utils import get_image_mime_type
|
from utils import get_image_mime_type
|
||||||
from utils import has_object_dict
|
from utils import has_object_dict
|
||||||
from utils import user_agent_domain
|
from utils import user_agent_domain
|
||||||
|
@ -3808,7 +3808,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
mediaFilenameBase = accountsDir + '/upload'
|
mediaFilenameBase = accountsDir + '/upload'
|
||||||
mediaFilename = \
|
mediaFilename = \
|
||||||
mediaFilenameBase + '.' + \
|
mediaFilenameBase + '.' + \
|
||||||
getImageExtensionFromMimeType(self.headers['Content-type'])
|
get_image_extension_from_mime_type(self.headers['Content-type'])
|
||||||
try:
|
try:
|
||||||
with open(mediaFilename, 'wb') as avFile:
|
with open(mediaFilename, 'wb') as avFile:
|
||||||
avFile.write(mediaBytes)
|
avFile.write(mediaBytes)
|
||||||
|
|
20
utils.py
20
utils.py
|
@ -378,7 +378,7 @@ def get_image_mime_type(image_filename: str) -> str:
|
||||||
return 'image/png'
|
return 'image/png'
|
||||||
|
|
||||||
|
|
||||||
def getImageExtensionFromMimeType(content_type: str) -> str:
|
def get_image_extension_from_mime_type(content_type: str) -> str:
|
||||||
"""Returns the image extension from a mime type, such as image/jpeg
|
"""Returns the image extension from a mime type, such as image/jpeg
|
||||||
"""
|
"""
|
||||||
image_media = {
|
image_media = {
|
||||||
|
@ -390,8 +390,8 @@ def getImageExtensionFromMimeType(content_type: str) -> str:
|
||||||
'avif': 'avif',
|
'avif': 'avif',
|
||||||
'x-icon': 'ico'
|
'x-icon': 'ico'
|
||||||
}
|
}
|
||||||
for mimeExt, ext in image_media.items():
|
for mime_ext, ext in image_media.items():
|
||||||
if content_type.endswith(mimeExt):
|
if content_type.endswith(mime_ext):
|
||||||
return ext
|
return ext
|
||||||
return 'png'
|
return 'png'
|
||||||
|
|
||||||
|
@ -407,14 +407,14 @@ def get_image_formats() -> str:
|
||||||
"""Returns a string of permissable image formats
|
"""Returns a string of permissable image formats
|
||||||
used when selecting an image for a new post
|
used when selecting an image for a new post
|
||||||
"""
|
"""
|
||||||
imageExt = get_image_extensions()
|
image_ext = get_image_extensions()
|
||||||
|
|
||||||
imageFormats = ''
|
image_formats = ''
|
||||||
for ext in imageExt:
|
for ext in image_ext:
|
||||||
if imageFormats:
|
if image_formats:
|
||||||
imageFormats += ', '
|
image_formats += ', '
|
||||||
imageFormats += '.' + ext
|
image_formats += '.' + ext
|
||||||
return imageFormats
|
return image_formats
|
||||||
|
|
||||||
|
|
||||||
def is_image_file(filename: str) -> bool:
|
def is_image_file(filename: str) -> bool:
|
||||||
|
|
Loading…
Reference in New Issue