-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[PE-95] chore: gif image support for all editors #6219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,7 +126,13 @@ def post(self, request): | |
| ) | ||
|
|
||
| # Check if the file type is allowed | ||
| allowed_types = ["image/jpeg", "image/png", "image/webp", "image/jpg"] | ||
| allowed_types = [ | ||
| "image/jpeg", | ||
| "image/png", | ||
| "image/webp", | ||
| "image/jpg", | ||
| "image/gif", | ||
| ] | ||
|
Comment on lines
+129
to
+135
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Centralize file type configuration and update error messages
Consider these improvements:
# Add to a new file: plane/utils/constants.py
class FileAssetConfig:
ALLOWED_MIME_TYPES = [
"image/jpeg",
"image/png",
"image/webp",
"image/jpg",
"image/gif",
]
@classmethod
def get_human_readable_types(cls):
return "JPEG, PNG, WebP, and GIF"
+from plane.utils.constants import FileAssetConfig
class UserAssetsV2Endpoint(BaseAPIView):
def post(self, request):
# ...
- allowed_types = [
- "image/jpeg",
- "image/png",
- "image/webp",
- "image/jpg",
- "image/gif",
- ]
- if type not in allowed_types:
+ if type not in FileAssetConfig.ALLOWED_MIME_TYPES:
return Response(
{
- "error": "Invalid file type. Only JPEG and PNG files are allowed.",
+ "error": f"Invalid file type. Only {FileAssetConfig.get_human_readable_types()} files are allowed.",
"status": False,
},
status=status.HTTP_400_BAD_REQUEST,
)Apply similar changes to WorkspaceFileAssetEndpoint and ProjectAssetEndpoint classes. |
||
| if type not in allowed_types: | ||
| return Response( | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,7 +86,13 @@ def post(self, request, anchor): | |
| ) | ||
|
|
||
| # Check if the file type is allowed | ||
| allowed_types = ["image/jpeg", "image/png", "image/webp"] | ||
| allowed_types = [ | ||
| "image/jpeg", | ||
| "image/png", | ||
| "image/webp", | ||
| "image/jpg", | ||
| "image/gif", | ||
| ] | ||
|
Comment on lines
+89
to
+95
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update error message to reflect all allowed image types. The error message only mentions JPEG and PNG files, but the Apply this diff to update the error message: if type not in allowed_types:
return Response(
{
- "error": "Invalid file type. Only JPEG and PNG files are allowed.",
+ "error": "Invalid file type. Only JPEG, PNG, WEBP, JPG, and GIF files are allowed.",
"status": False,
},
status=status.HTTP_400_BAD_REQUEST,
)
|
||
| if type not in allowed_types: | ||
| return Response( | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update error message in UserAssetsV2Endpoint to reflect all allowed image types.
The error message only mentions JPEG and PNG files, but the
allowed_typeslist includes WEBP, JPG, and GIF.Apply this diff to update the error message:
if type not in allowed_types: return Response( { - "error": "Invalid file type. Only JPEG and PNG files are allowed.", + "error": "Invalid file type. Only JPEG, PNG, WEBP, JPG, and GIF files are allowed.", "status": False, }, status=status.HTTP_400_BAD_REQUEST, )