Skip to content

Commit

Permalink
Merge pull request #24 from keyko-io/fix/filename-download
Browse files Browse the repository at this point in the history
Don't use http query parameters in filename
  • Loading branch information
aaitor committed Sep 22, 2020
2 parents 6e18be9 + b902009 commit 72533d9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.4.1
current_version = 0.4.2
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
author = 'nevermined-sdk-py contributors'

# The full version, including alpha/beta/rc tags
release = '0.4.1'
release = '0.4.2'
# The short X.Y version
release_parts = release.split('.') # a list
version = release_parts[0] + '.' + release_parts[1]
Expand Down
2 changes: 1 addition & 1 deletion nevermined_sdk_py/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.4.1'
__version__ = '0.4.2'
from .config import (
Config
)
Expand Down
2 changes: 1 addition & 1 deletion nevermined_sdk_py/gateway/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def get_ecdsa_public_key(config):
@staticmethod
def _get_file_name(response):
try:
return re.match(r'attachment;filename=(.+)',
return re.match(r'attachment;filename=(.+?)($|\?)',
response.headers.get('content-disposition'))[1]
except Exception as e:
logger.warning(f'It was not possible to get the file name. {e}')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/keyko-io/nevermined-sdk-py',
version='0.4.1',
version='0.4.2',
zip_safe=False,
)
16 changes: 16 additions & 0 deletions tests/gateway/test_gateway.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
from nevermined_sdk_py import ConfigProvider
from nevermined_sdk_py.gateway.gateway import Gateway
from requests import Response

config = ConfigProvider.get_config()


def test_get_rsa_key():
assert Gateway.get_rsa_public_key(config)


def test_get_file_name():
response = Response()

response.headers = {"content-disposition": "attachment;filename=test.txt"}
print(response.headers.get("content-disposition"))
file_name = Gateway._get_file_name(response)
assert file_name == "test.txt"

response.headers = {
"content-disposition": "attachment;filename=test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256"
}
file_name = Gateway._get_file_name(response)
assert file_name == "test.txt"

0 comments on commit 72533d9

Please sign in to comment.