-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add content-length-range to pre-signed URL config (#32)
* Add content-length-range to pre-signed URL config * Add file-size check to test.views.fake_s3_upload * Add MAX_FILE_SIZE setting to README * Bump version to 0.1.21
- Loading branch information
1 parent
010ac34
commit 2f83507
Showing
12 changed files
with
81 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.1.20' | ||
__version__ = '0.1.21' |
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,9 @@ | ||
EXCEED_MAX_SIZE = """ | ||
<Error> | ||
<Code>EntityTooLarge</Code> | ||
<Message>Your proposed upload exceeds the maximum | ||
allowed size</Message> | ||
<MaxSizeAllowed>{max_size}</MaxSizeAllowed> | ||
<ProposedSize>{proposed_size}</ProposedSize> | ||
</Error> | ||
""" |
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 |
---|---|---|
@@ -1,15 +1,24 @@ | ||
from django.conf import settings | ||
from django.core.files.storage import default_storage | ||
from django.views.decorators.csrf import csrf_exempt | ||
from django.views.decorators.http import require_POST | ||
from django.http import HttpResponse | ||
|
||
from .errors import EXCEED_MAX_SIZE | ||
|
||
|
||
@csrf_exempt | ||
@require_POST | ||
def fake_s3_upload(request): | ||
key = request.POST.get('key') | ||
|
||
file = request.FILES.get('file') | ||
default_storage.save(key, file.read()) | ||
|
||
max_file_size = settings.AWS.get('MAX_FILE_SIZE') | ||
if max_file_size and file.size > max_file_size: | ||
msg = EXCEED_MAX_SIZE.format(max_size=max_file_size, | ||
proposed_size=file.size) | ||
return HttpResponse(msg, status=400) | ||
|
||
default_storage.save(key, file.read()) | ||
return HttpResponse('', status=204) |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Minimum Django version | ||
Django==1.11.3 | ||
Django>=1.10,<1.11 | ||
boto3==1.4.4 | ||
|
||
# Test requirements | ||
|
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