-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to boto3's generate_presigned_post method
- Loading branch information
Showing
12 changed files
with
95 additions
and
120 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,16 +1,20 @@ | ||
from django.apps import AppConfig | ||
from django.conf import settings | ||
|
||
try: | ||
from storages.backends.s3boto3 import S3Boto3Storage | ||
except ImportError: | ||
from storages.backends.s3boto import S3BotoStorage as S3BotoStorage | ||
|
||
|
||
class S3FileConfig(AppConfig): | ||
name = 's3file' | ||
verbose_name = "S3File" | ||
verbose_name = 'S3File' | ||
|
||
def ready(self): | ||
from django.forms import FileField | ||
from django.core.files.storage import default_storage | ||
|
||
if hasattr(settings, 'AWS_SECRET_ACCESS_KEY') \ | ||
and settings.AWS_SECRET_ACCESS_KEY: | ||
if isinstance(default_storage, S3Boto3Storage): | ||
from .forms import S3FileInput | ||
|
||
FileField.widget = S3FileInput |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from django.core.files.storage import FileSystemStorage | ||
|
||
try: | ||
from django.urls import reverse | ||
except ImportError: | ||
# Django 1.8 support | ||
from django.core.urlresolvers import reverse | ||
|
||
|
||
class DummyS3Boto3Storage(FileSystemStorage): | ||
class connection: | ||
class meta: | ||
class client: | ||
@staticmethod | ||
def generate_presigned_post(*args, **kargs): | ||
return { | ||
'url': reverse('s3mock'), | ||
'fields': { | ||
'x-amz-algorithm': 'AWS4-HMAC-SHA256', | ||
'x-amz-date': '20170908T111600Z', | ||
'x-amz-signature': 'asdf', | ||
'x-amz-credential': 'testaccessid', | ||
'policy': 'asdf', | ||
'key': 'tmp/${filename}', | ||
}, | ||
} | ||
|
||
class bucket: | ||
name = 'test-bucket' |
Oops, something went wrong.