-
Notifications
You must be signed in to change notification settings - Fork 12
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
🏷️(backend) add content-type to uploaded files #552
base: main
Are you sure you want to change the base?
Conversation
1fcc576
to
e39fab4
Compare
1fa20e6
to
012af6f
Compare
45b9fbc
to
8db58c7
Compare
All the uploaded files had the content-type set to `application/octet-stream`. It create issues when the file is downloaded from the frontend because the browser doesn't know how to handle the file. We now determine the content-type of the file and set it to the file object.
Add django-test-migrations to the project. It is a tool that helps to test Django migrations.
The uploaded files in the system are missing the content-type. We add a migration to update the content-type of the existing uploaded files.
8db58c7
to
5711bf5
Compare
from django.db import migrations | ||
from django.core.files.storage import default_storage | ||
|
||
def fix_attachments_content_type(apps, schema_editor): |
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.
All of this should be made in a management command. It is a not related to a database modification and tests should be added IMO
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.
And so we have to create a job in the helm chart to run this kind of management command. I will made it in this branch if you are ok
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.
Yes feel free to do it. 🙏
For a specific deployment we may need to run a specific management command, like the one added previously updating all files content-type. A template is added responsible to manage this case. The job will be created only if the backend.job.command is set.
@AntoLC I updated the PR accordingly with my last suggestion. |
Purpose
All the uploaded files had the content-type set to
application/octet-stream
. It create issues when the file is downloaded from the frontend because the browser doesn't know how to handle the file.Proposal
We improved the mimetype database and we now determine the content-type of the file and set it to the file object.