Giter Site home page Giter Site logo

kaleidos / django-validated-file Goto Github PK

View Code? Open in Web Editor NEW
32.0 7.0 25.0 83 KB

ATTENTION: there is a fork of this utility, at https://github.com/mbourqui/django-constrainedfilefield, that is more maintained and updated, and adds some nice features like a javascript validator. We recommend using ConstrainedFileField instead of ValidatedFile.

License: BSD 3-Clause "New" or "Revised" License

Shell 0.57% Python 99.43%

django-validated-file's People

Contributors

burhan avatar epicfaace avatar hirunatan avatar jarus avatar jespino avatar movermeyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-validated-file's Issues

Correct file extension based on mimetype

Hi,

it would be a nice feature to change the file extension of the uploaded file to a guest file extension from mimetype. Sometimes users uploads images or other files with the wrong extension.

I already implemented this functionality but this currently requires a subclass of FieldFile.

Order of file size check and mime type check should be changed

With .doc files from older MS Word, libmagic via the buffer interface on Unbuntu 14 is unable to identify the mime type unless the entire file is passed in the buffer. (Perhaps this issue occurs with other MIME types as well.) Otherwise, the returned mime type is "application/CDFV2-corrupt", which should fail the content-type check. The user will be told that "application/CDFV2-corrupt" is not supported, which is not something they can deal with effectively. A partial work-around for this is to set mime_upload_length to the max file size supported so that the entire file contents are provided to libmagic. However, that has a remaining case where the user is unnecessarily misled by an error message:

  • if the actual mime type is "application/msword" but the file size exceeds the limit (and thus mime_upload_length), the error presented to the user will be a mime type error (because not enough data was passed to libmagic) instead of a file length error.

This confusing message can be resolved simply by changing the order of the file size and mime type checks.

(For some use cases this still might not be a workable solution because of the need to process the file contents in memory. That could be mitigated by reading additional data if the data in a "small" buffer cannot be identified.)

magic issue on windows?

It looks from the python-magic documentation that:

You will need to copy the file magic out of [binary-zip]\share\misc, and pass it's location to Magic(magic_file=...).

I noticed that in this library, though, magic_file is not passed as a parameter when Magic is initialized -- the code is merely magic.Magic(mime=True). Is there another way that this library works with Windows -- or does the existing source code only work for Linux/Mac?

Make the field compatible with south

I'm using Django 1.5. with south 0.8.2 and valideated file version (2, 0, 0, 'final', 0).

When I do a schema migration an error accures.

./manage.py schemamigration project_name --auto

 ! Cannot freeze field 'student_upload.rad.datoteka'
 ! (this field has class validatedfile.fields.ValidatedFileField)

 ! South cannot introspect some fields; this is probably because they are custom
 ! fields. If they worked in 0.6 or below, this is because we have removed the
 ! models parser (it often broke things).
 ! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork

The method for fixing is defined on the link http://south.aeracode.org/wiki/MyFieldsDontWork

MagicException Error.. Failed To Load

Thanks for creating this package. After setting everything, I tested it out but I'm getting "Can't find any magic files" Please where can I explictly set the path to magic files (DLL's) on windows? I'm finding it difficult to do this.

You can not install django-validate-file without preinstalled django

If you create a new virtualenv and would install django-validated-file from git than you have to install django first. A requirements file like the following doesn't work.

django
-e git+https://github.com/jarus/django-validated-file.git@4ffeac17cf41c695daca6135b337508769ae1b3d#egg=django_validated_file-dev

The problem is that there are imports of django in the init.py and also for python-magic.

Python 3.6 error

When installing

\AppData\Local\Temp\pip-build-4_aisjs5\distribute\pkg_resources.py", line 1518, in <module> register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider) AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.