Skip to content

Commit

Permalink
Merge pull request bradleyg#11 from yunojuno/feature/valid-filename
Browse files Browse the repository at this point in the history
Feature/valid filename
  • Loading branch information
hugorodgerbrown committed Aug 23, 2017
2 parents df74dcc + 210eea8 commit a3a4193
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
3 changes: 2 additions & 1 deletion s3upload/fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.conf import settings
from django.db.models import Field
from django.utils.text import get_valid_filename

from .widgets import S3UploadWidget
from .utils import remove_signature, get_path_from_url
Expand Down Expand Up @@ -34,7 +35,7 @@ def pre_save(self, model_instance, add):
'bucket', settings.AWS_STORAGE_BUCKET_NAME
)
path = get_path_from_url(no_signature_url, bucket_name=bucket_name)
return path
return get_valid_filename(path)

return file_url

Expand Down
11 changes: 1 addition & 10 deletions s3upload/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
from django.conf import settings


class KeyNotFoundException(Exception):
pass


def get_at(index, t):
try:
value = t[index]
Expand Down Expand Up @@ -197,12 +193,7 @@ def get_signed_download_url(

bucket = conn.get_bucket(bucket_name)
k = Key(bucket)

try:
k.key = key
except AttributeError:
# key has no 'name' because it's not present in the bucket
raise KeyNotFoundException
k.key = key

download_url = k.generate_url(
expires_in=ttl,
Expand Down

0 comments on commit a3a4193

Please sign in to comment.