Commits

paulswartz committed e5fd59e

add BUCKET_PREFIX support to s3boto

Comments (0)

Files changed (1)

storages/backends/s3boto.py

 AUTO_CREATE_BUCKET  = getattr(settings, 'AWS_AUTO_CREATE_BUCKET', False)
 DEFAULT_ACL         = getattr(settings, 'AWS_DEFAULT_ACL', 'public-read')
 BUCKET_ACL          = getattr(settings, 'AWS_BUCKET_ACL', DEFAULT_ACL)
+BUCKET_PREFIX       = getattr(settings, 'AWS_BUCKET_PREFIX', '')
 QUERYSTRING_AUTH    = getattr(settings, 'AWS_QUERYSTRING_AUTH', True)
 QUERYSTRING_EXPIRE  = getattr(settings, 'AWS_QUERYSTRING_EXPIRE', 3600)
 REDUCED_REDUNDANCY  = getattr(settings, 'AWS_REDUCED_REDUNDANCY', False)
 
     def _clean_name(self, name):
         # Useful for windows' paths
-        return os.path.normpath(name).replace('\\', '/')
+        if not name.startswith('%s/' % BUCKET_PREFIX):
+            prefix_string = BUCKET_PREFIX
+        else:
+            prefix_string = ''
+        return os.path.join(prefix_string, os.path.normpath(name).replace('\\', '/'))
 
     def _normalize_name(self, name):
         try: