Created
November 20, 2014 17:42
-
-
Save maracuja/40f26f3f72bdde2d89f7 to your computer and use it in GitHub Desktop.
Save to S3
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
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' | |
AWS_S3_SECURE_URLS = False | |
AWS_QUERYSTRING_AUTH = False | |
AWS_S3_ACCESS_KEY_ID = "" | |
AWS_S3_SECRET_ACCESS_KEY = "" | |
AWS_STORAGE_BUCKET_NAME = 'bucket_name' | |
AWS_HEADERS = { | |
'Expires': 'Thu, 15 Apr 2010 20:00:00 GMT', | |
'Cache-Control': 'max-age=86400', | |
'Content-Type': 'text/xml' | |
} |
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
from django.core.files.storage import default_storage | |
def your_view(request): | |
xml_contents = 'SITEMAP XML HERE' | |
sitemap_url = '/sitemaps/YYYY/MM/DD-sitemap.xml' | |
s3_key = default_storage.open(sitemap_url, 'w') | |
s3_key.write(xml_contents) | |
s3_key.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment