Showing
5 changed files
with
2 additions
and
53 deletions
| ... | @@ -23,7 +23,6 @@ INSTALLED_APPS = [ | ... | @@ -23,7 +23,6 @@ INSTALLED_APPS = [ |
| 23 | 'rest_framework', | 23 | 'rest_framework', |
| 24 | 'restful.apps.RestfulConfig', | 24 | 'restful.apps.RestfulConfig', |
| 25 | 'website', | 25 | 'website', |
| 26 | - 's3direct', | ||
| 27 | ] | 26 | ] |
| 28 | 27 | ||
| 29 | MIDDLEWARE = [ | 28 | MIDDLEWARE = [ |
| ... | @@ -122,44 +121,4 @@ LOGIN_REDIRECT_URL = '/' | ... | @@ -122,44 +121,4 @@ LOGIN_REDIRECT_URL = '/' |
| 122 | AWS_ACCESS_KEY_ID = aws_conf.AWS_ACCESS_KEY_ID | 121 | AWS_ACCESS_KEY_ID = aws_conf.AWS_ACCESS_KEY_ID |
| 123 | AWS_SECRET_ACCESS_KEY = aws_conf.AWS_SECRET_ACCESS_KEY | 122 | AWS_SECRET_ACCESS_KEY = aws_conf.AWS_SECRET_ACCESS_KEY |
| 124 | 123 | ||
| 125 | -AWS_STORAGE_BUCKET_NAME = aws_conf.AWS_STORAGE_BUCKET_NAME | 124 | +AWS_STORAGE_BUCKET_NAME = aws_conf.AWS_STORAGE_BUCKET_NAME |
| 126 | - | ||
| 127 | -# The region of your bucket, more info: | ||
| 128 | -# http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region | ||
| 129 | -S3DIRECT_REGION = 'ap-northeast-2' | ||
| 130 | - | ||
| 131 | -# Destinations, with the following keys: | ||
| 132 | -# | ||
| 133 | -# key [required] Where to upload the file to, can be either: | ||
| 134 | -# 1. '/' = Upload to root with the original filename. | ||
| 135 | -# 2. 'some/path' = Upload to some/path with the original filename. | ||
| 136 | -# 3. functionName = Pass a function and create your own path/filename. | ||
| 137 | -# key_args [optional] Arguments to be passed to 'key' if it's a function. | ||
| 138 | -# auth [optional] An ACL function to whether the current Django user can perform this action. | ||
| 139 | -# allowed [optional] List of allowed MIME types. | ||
| 140 | -# acl [optional] Give the object another ACL rather than 'public-read'. | ||
| 141 | -# cache_control [optional] Cache control headers, eg 'max-age=2592000'. | ||
| 142 | -# content_disposition [optional] Useful for sending files as attachments. | ||
| 143 | -# bucket [optional] Specify a different bucket for this particular object. | ||
| 144 | -# server_side_encryption [optional] Encryption headers for buckets that require it. | ||
| 145 | - | ||
| 146 | -S3DIRECT_DESTINATIONS = { | ||
| 147 | - 'example_destination': { | ||
| 148 | - # REQUIRED | ||
| 149 | - 'key': '/', | ||
| 150 | - | ||
| 151 | - # OPTIONAL | ||
| 152 | - #'auth': lambda u: u.is_staff, # Default allow anybody to upload | ||
| 153 | - #'allowed': ['image/jpeg', 'image/png', 'video/mp4'], # Default allow all mime types | ||
| 154 | - #'bucket': 'pdf-bucket', # Default is 'AWS_STORAGE_BUCKET_NAME' | ||
| 155 | - 'acl': 'private', # Defaults to 'public-read' | ||
| 156 | - 'cache_control': 'max-age=2592000', # Default no cache-control | ||
| 157 | - #'content_disposition': 'attachment', # Default no content disposition | ||
| 158 | - #'content_length_range': (5000, 20000000), # Default allow any size | ||
| 159 | - #'server_side_encryption': 'AES256', # Default no encryption | ||
| 160 | - }, | ||
| 161 | - 'example_other': { | ||
| 162 | - 'key': lambda filename, args: args + '/' + filename, | ||
| 163 | - 'key_args': 'uploads/images', # Only if 'key' is a function | ||
| 164 | - } | ||
| 165 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -10,6 +10,5 @@ urlpatterns = [ | ... | @@ -10,6 +10,5 @@ urlpatterns = [ |
| 10 | url(r'^accounts/login/$', views.login, name='login'), | 10 | url(r'^accounts/login/$', views.login, name='login'), |
| 11 | url(r'^accounts/logout/$', views.logout, name='logout', kwargs={'next_page': '/'}), | 11 | url(r'^accounts/logout/$', views.logout, name='logout', kwargs={'next_page': '/'}), |
| 12 | 12 | ||
| 13 | - url(r'^s3direct/', include('s3direct.urls')), | ||
| 14 | ] | 13 | ] |
| 15 | 14 | ... | ... |
| 1 | -from django.db import models | ||
| 2 | -from s3direct.fields import S3DirectField | ||
| 3 | - | ||
| 4 | -class Example(models.Model): | ||
| 5 | - video = S3DirectField(dest='example_destination') | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +from django.db import models | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -2,7 +2,6 @@ from django.shortcuts import render, get_object_or_404, redirect, Http404 | ... | @@ -2,7 +2,6 @@ from django.shortcuts import render, get_object_or_404, redirect, Http404 |
| 2 | from django.utils import timezone | 2 | from django.utils import timezone |
| 3 | from django.contrib.auth.decorators import login_required | 3 | from django.contrib.auth.decorators import login_required |
| 4 | from django.views.generic import FormView | 4 | from django.views.generic import FormView |
| 5 | -from website.forms import S3DirectUploadForm | ||
| 6 | from restful.models import File | 5 | from restful.models import File |
| 7 | import requests | 6 | import requests |
| 8 | 7 | ... | ... |
-
Please register or login to post a comment