Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Django Private Storage
Commits
21a80cc3
Commit
21a80cc3
authored
Oct 10, 2016
by
Diederik van der Boor
Browse files
Add logger statement to see the content type of rejected uploads
parent
2b1d0347
Changes
1
Show whitespace changes
Inline
Side-by-side
private_storage/fields.py
View file @
21a80cc3
#-*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
logging
import
os
import
django
...
...
@@ -11,6 +13,9 @@ from django.utils.encoding import smart_str
from
django.utils.translation
import
ugettext_lazy
as
_
from
.storage
import
private_storage
logger
=
logging
.
getLogger
(
__name__
)
class
PrivateFileField
(
models
.
FileField
):
"""
...
...
@@ -45,6 +50,7 @@ class PrivateFileField(models.FileField):
content_type
=
file
.
content_type
if
self
.
content_types
and
content_type
not
in
self
.
content_types
:
logger
.
debug
(
'Rejected uploaded file type: %s'
,
content_type
)
raise
ValidationError
(
self
.
error_messages
[
'invalid_file_type'
])
if
self
.
max_file_size
and
file
.
size
>
self
.
max_file_size
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment