Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Store mimetype of uploaded file in database (#1152) * Store mimetype of uploaded file in database * Fix a few CI errors * set default mime_type to application/octet-stream * Server.serve() now accepts a filer.File object * Fix: JPG testimage shall be uploaded with Content-Type image/jpeg * fix flake8 complaints * Use NotImplementedError * fix flake8 complaints * describe changes * use master branch instead of develop * add additional tests to support MIME type * check that content-type is stored by django-filer * Allow latest unidecode version (#1171) * Allow latest unidecode version Resolves dependency issue in other projects where Unidecode >= 1.1 is needed. * Fix annotation by @yakky on PR #1152 * use url instead of path to guess mime-type * Use property ‘download’ to reuse original filename (#1169) * Use property ‘download’ to reuse original filename * add feature to changelog Co-authored-by: Angelo Dini <angelo.dini@divio.ch> Co-authored-by: Ashish Patil <ashishnitinpatil@gmail.com> * Edit documentation * fix flake * adapt changelog Co-authored-by: Jacob Rief <jacob.rief@gmail.com> Co-authored-by: Ashish Patil <ashishnitinpatil@gmail.com> Co-authored-by: Iacopo Spalletti <i.spalletti@nephila.digital>
- Loading branch information
1 parent
29eea04
commit 3ba0e04
Showing
14 changed files
with
161 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 2.1.9 on 2019-06-25 19:12 | ||
|
||
import mimetypes | ||
|
||
from django.db import migrations, models | ||
|
||
import filer.models.filemodels | ||
|
||
|
||
def guess_mimetypes(apps, schema_editor): | ||
FileModel = apps.get_model('filer', 'File') | ||
for file_obj in FileModel.objects.all(): | ||
file_obj.mime_type, _ = mimetypes.guess_type(file_obj.file.url) | ||
file_obj.save(update_fields=['mime_type']) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('filer', '0011_auto_20190418_0137'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='file', | ||
name='mime_type', | ||
field=models.CharField(default='application/octet-stream', help_text='MIME type of uploaded content', max_length=255, validators=[filer.models.filemodels.mimetype_validator]), | ||
), | ||
migrations.RunPython(guess_mimetypes, reverse_code=migrations.RunPython.noop), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.