Skip to content

Commit

Permalink
Call load_async when delegating to http_loader.
Browse files Browse the repository at this point in the history
  • Loading branch information
aectann committed Jun 16, 2015
1 parent ced7398 commit 85835db
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions thumbor_aws/loaders/s3_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ def _get_bucket(url):
return bucket_name, bucket_path


def _normalize_url(url):
"""
:param url:
:return: exactly the same url since we only use http loader if url stars with http prefix.
"""
return url


def _validate_bucket(context, bucket):
allowed_buckets = context.config.get('S3_ALLOWED_BUCKETS', default=None)
return not allowed_buckets or bucket in allowed_buckets
Expand All @@ -30,9 +38,8 @@ def _validate_bucket(context, bucket):
def load(context, url, callback):
enable_http_loader = context.config.get('AWS_ENABLE_HTTP_LOADER', default=False)

if enable_http_loader and 'http' in url:
http_loader.load(context, url, callback)
return
if enable_http_loader and url.startswith('http'):
return http_loader.load_sync(context, url, callback, normalize_url_func=_normalize_url)

url = urllib2.unquote(url)

Expand All @@ -56,4 +63,4 @@ def load(context, url, callback):
callback(file_key.read())
return

callback(None)
callback(None)

0 comments on commit 85835db

Please sign in to comment.