-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for Content-Disposition: inline
Actually all these changes do is supporting an incoming `?preview=1` query argument on download URLs and forward the `x-disposition = inline` extra to Giftless when requesting the download URL. At that point datopian/giftless#90 will kick in and the storage backend will return the appropiate headers. The only way to pass this parameter all the way down to the action that requests the downloadURL was to add a new argument to the download handlers. This would break backwards compatibility so I've added code to support plugin hooks that don't support the new `inline` arg.
- Loading branch information
Showing
6 changed files
with
110 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import mock | ||
import pytest | ||
|
||
from ckan.plugins import toolkit | ||
from ckan.tests import factories | ||
|
||
|
||
@pytest.mark.usefixtures('clean_db') | ||
def test_preview_arg(app): | ||
|
||
org = factories.Organization() | ||
dataset = factories.Dataset(owner_org=org['id']) | ||
resource = factories.Resource( | ||
package_id=dataset['id'], | ||
url_type='upload', | ||
sha256='cc71500070cf26cd6e8eab7c9eec3a937be957d144f445ad24003157e2bd0919', | ||
size=12, | ||
lfs_prefix='lfs/prefix' | ||
) | ||
|
||
with mock.patch('ckanext.blob_storage.blueprints.call_download_handlers') as m: | ||
|
||
m.return_value = '' | ||
|
||
url = toolkit.url_for( | ||
'blob_storage.download', | ||
id=dataset['id'], | ||
resource_id=resource['id'], | ||
preview=1 | ||
) | ||
|
||
app.get(url) | ||
|
||
args = m.call_args | ||
|
||
assert args[0][0]['id'] == resource['id'] # resource | ||
assert args[0][1]['id'] == dataset['id'] # dataset | ||
assert args[0][2] is None # filename | ||
assert args[0][3] is True # inline | ||
|
||
url = toolkit.url_for( | ||
'blob_storage.download', | ||
id=dataset['id'], | ||
resource_id=resource['id'], | ||
filename='test.csv', | ||
preview=1 | ||
) | ||
|
||
app.get(url) | ||
|
||
args = m.call_args | ||
|
||
assert args[0][2] == 'test.csv' # filename | ||
assert args[0][3] is True # inline | ||
|
||
url = toolkit.url_for( | ||
'blob_storage.download', | ||
id=dataset['id'], | ||
resource_id=resource['id'], | ||
filename='test.csv', | ||
) | ||
|
||
app.get(url) | ||
|
||
args = m.call_args | ||
|
||
assert args[0][3] is False # inline |