From 85835dbfc2fb688731f1d6e41cdf5043e6ee59d2 Mon Sep 17 00:00:00 2001 From: Konstantin Burov Date: Tue, 16 Jun 2015 20:01:02 +1000 Subject: [PATCH] Call load_async when delegating to http_loader. --- thumbor_aws/loaders/s3_loader.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/thumbor_aws/loaders/s3_loader.py b/thumbor_aws/loaders/s3_loader.py index 9774171..dd19a11 100644 --- a/thumbor_aws/loaders/s3_loader.py +++ b/thumbor_aws/loaders/s3_loader.py @@ -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 @@ -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) @@ -56,4 +63,4 @@ def load(context, url, callback): callback(file_key.read()) return - callback(None) \ No newline at end of file + callback(None)