aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDev Server2010-07-14 14:56:20 -0600
committerDev Server2010-07-14 14:56:20 -0600
commit1fe1bc393b3dc58a0df2e3a1a24a1c8b95d0b862 (patch)
tree35bb81e4d49caca3b71abc29d21e9615c28c0ba9
parentfbc5dadbd6134168eb6516bc2e106e88a2fa3a7f (diff)
downloadamazons3-py-1fe1bc393b3dc58a0df2e3a1a24a1c8b95d0b862.tar.gz
amazons3-py-1fe1bc393b3dc58a0df2e3a1a24a1c8b95d0b862.zip
added CxStorage class which hashes the filename
-rw-r--r--django/__init__.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/django/__init__.py b/django/__init__.py
index 10d6728..bb650a5 100644
--- a/django/__init__.py
+++ b/django/__init__.py
@@ -3,6 +3,7 @@ from amazons3 import S3
3 3
4from django.core.files.storage import Storage 4from django.core.files.storage import Storage
5 5
6
6class S3Error(Exception): 7class S3Error(Exception):
7 "Misc. S3 Service Error" 8 "Misc. S3 Service Error"
8 pass 9 pass
@@ -127,3 +128,26 @@ class S3Storage(Storage):
127 filename = '%s-%d%s' % (basefilename[0], i, basefilename[1]) 128 filename = '%s-%d%s' % (basefilename[0], i, basefilename[1])
128 129
129 return filename 130 return filename
131
132class CxStorage(S3Storage):
133 """
134 This storage engine provides the naming scheme for phonese3. It hashes
135 the file names before storage.
136 To use, set DEFAULT_STORAGE_ENGINE="CxStorage"
137
138 Author: Jason Braegger
139 License: AGPLv3
140 Source: http://code.twi.gs/phonese3/
141 """
142 def get_valid_name(self, name):
143 """
144 This returns a hashed name to use for storage on the filesystem
145 """
146 import os.path
147 from hashlib import md5
148 import time
149
150 extension = os.path.splitext(name)[1].lower()
151
152 return str(md5(str(time.time()) + str(name)).hexdigest()) + \
153 str(extension)