Skip to content

Commit 5075b99

Browse files
author
Bartek Kwiecien
committed
Merge branch 'release/3.5.0'
2 parents e19c7e7 + 5ee85fe commit 5075b99

File tree

8 files changed

+22
-12
lines changed

8 files changed

+22
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Filestack-Python Changelog
22

3+
### 3.5.0 (September 17th, 2021)
4+
- Broaden pinned requests version from 2.24.0 to >=2.25.1 [#61](https://github.com/filestack/filestack-python/pull/61)
5+
- Use Client's storage when uploading external urls [#62](https://github.com/filestack/filestack-python/pull/62)
6+
37
### 3.4.0 (May 13th, 2021)
48
- Store upload response in Filelink object [#59](https://github.com/filestack/filestack-python/pull/59)
59

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.4.0
1+
3.5.0

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Sphinx==2.1.2
22
sphinx-rtd-theme==0.4.3
33
trafaret==2.0.2
4-
requests==2.24.0
4+
requests>=2.25.1

filestack/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '3.4.0'
1+
__version__ = '3.5.0'
22

33

44
class CFG:

filestack/models/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def upload_url(self, url, store_params=None, security=None):
120120
:class:`filestack.Filelink`: new Filelink object
121121
"""
122122
sec = security or self.security
123-
upload_response = upload_external_url(url, self.apikey, store_params, security=sec)
123+
upload_response = upload_external_url(url, self.apikey, self.storage, store_params, security=sec)
124124
return filestack.models.Filelink(
125125
handle=upload_response['handle'],
126126
apikey=self.apikey,

filestack/uploads/external_url.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
from filestack.utils import requests
33

44

5-
def upload_external_url(url, apikey, store_params=None, security=None):
5+
def upload_external_url(url, apikey, storage, store_params=None, security=None):
66
store_params = store_params or {}
7+
if storage and not store_params.get('location'):
8+
store_params['location'] = storage
79

810
# remove params that are currently not supported in external url upload
911
for item in ('mimetype', 'upload_tags'):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def read_version():
2323
author_email='support@filestack.com',
2424
packages=find_packages(),
2525
install_requires=[
26-
'requests==2.25.1',
26+
'requests>=2.25.1',
2727
'trafaret==2.0.2'
2828
],
2929
classifiers=[

tests/uploads/test_upload_external_url.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,24 @@
1010
apikey = 'TESTAPIKEY'
1111

1212

13-
@pytest.mark.parametrize('store_params, security, expected_store_tasks', [
13+
@pytest.mark.parametrize('default_storage, store_params, security, expected_store_tasks', [
1414
(
15-
{'location': 's3'},
15+
'S3,',
16+
{'location': 'gcs'},
1617
None,
1718
[
1819
{
19-
'name': 'store', 'params': {'location': 's3'}
20+
'name': 'store', 'params': {'location': 'gcs'}
2021
}
2122
]
2223
),
2324
(
25+
'gcs',
2426
{'path': 'new-path/', 'mimetype': 'application/json'},
2527
type('SecurityMock', (), {'policy_b64': 'abc', 'signature': '123'}),
2628
[
2729
{
28-
'name': 'store', 'params': {'path': 'new-path/'}
30+
'name': 'store', 'params': {'path': 'new-path/', 'location': 'gcs'}
2931
},
3032
{
3133
'name': 'security', 'params': {'policy': 'abc', 'signature': '123'}
@@ -34,15 +36,17 @@
3436
)
3537
])
3638
@patch('filestack.uploads.external_url.requests.post')
37-
def test_upload_with_store_params(post_mock, store_params, security, expected_store_tasks):
39+
def test_upload_with_store_params(post_mock, default_storage, store_params, security, expected_store_tasks):
3840
expected_payload = {
3941
'apikey': 'TESTAPIKEY',
4042
'sources': ['http://image.url'],
4143
'tasks': expected_store_tasks
4244
}
4345
post_mock.return_value = DummyHttpResponse(json_dict={'handle': 'newHandle'})
4446

45-
upload_response = upload_external_url(url, apikey, store_params=store_params, security=security)
47+
upload_response = upload_external_url(
48+
url, apikey, default_storage, store_params=store_params, security=security
49+
)
4650
assert upload_response['handle'] == 'newHandle'
4751
post_args, _ = post_mock.call_args
4852
post_mock.assert_called_once_with('{}/process'.format(config.CDN_URL), json=expected_payload)

0 commit comments

Comments
 (0)