|
1 |
| -import os |
2 | 1 | import json
|
3 | 2 | import hashlib
|
4 | 3 | import logging
|
5 |
| -from urllib.parse import urlparse |
6 | 4 | import mimetypes
|
| 5 | +import os |
| 6 | +from urllib.parse import urlparse |
7 | 7 |
|
8 | 8 | import furl
|
9 | 9 | import aiohttp
|
10 | 10 | from aiohttp.errors import ContentEncodingError
|
11 | 11 |
|
12 | 12 | from waterbutler.core import streams
|
13 | 13 |
|
14 |
| -from mfr.core import exceptions |
15 |
| -from mfr.core import provider |
| 14 | +from mfr.core import exceptions, provider |
| 15 | +from mfr.core.exceptions import TooBigToRenderError |
16 | 16 | from mfr.core.utils import sizeof_fmt
|
17 | 17 | from mfr.providers.osf import settings
|
18 | 18 | from mfr.settings import MAX_FILE_SIZE_TO_RENDER
|
19 |
| -from mfr.core.exceptions import TooBigToRenderError |
20 | 19 |
|
21 | 20 | logger = logging.getLogger(__name__)
|
22 | 21 |
|
@@ -121,18 +120,16 @@ async def metadata(self):
|
121 | 120 | unique_key = hashlib.sha256((metadata['data']['etag'] + cleaned_url.url).encode('utf-8')).hexdigest()
|
122 | 121 |
|
123 | 122 | is_public = False
|
124 |
| - |
125 |
| - if 'public_file' in cleaned_url.args: |
126 |
| - if cleaned_url.args['public_file'] not in ['0', '1']: |
| 123 | + public_file = cleaned_url.args.get('public_file', None) |
| 124 | + if public_file: |
| 125 | + if public_file not in ['true', 'false']: |
127 | 126 | raise exceptions.QueryParameterError(
|
128 |
| - 'The `public_file` query paramter should either `0`, `1`, or unused. Instead ' |
129 |
| - 'got {}'.format(cleaned_url.args['public_file']), |
| 127 | + 'Invalid value for query parameter `public_file`: {}'.format(cleaned_url.args['public_file']), |
130 | 128 | url=download_url,
|
131 | 129 | provider=self.NAME,
|
132 | 130 | code=400,
|
133 | 131 | )
|
134 |
| - |
135 |
| - is_public = cleaned_url.args['public_file'] == '1' |
| 132 | + is_public = public_file == 'true' |
136 | 133 |
|
137 | 134 | return provider.ProviderMetadata(name, ext, content_type,
|
138 | 135 | unique_key, download_url, is_public=is_public)
|
|
0 commit comments