Skip to content

Commit de26adf

Browse files
authored
Merge pull request #253 from ehossack/fix/bucket-name-restrictions
Fix an issue calling incorrect api
2 parents cf16a08 + 8fe7a35 commit de26adf

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
* Refactored `FileVersionInfo` to `FileVersion`
1616
* `ScanPoliciesManager` exclusion interface changed
1717

18+
### Fixed
19+
* Fix call to incorrect internal api in `B2Api.get_download_url_for_file_name`
20+
1821
## [1.8.0] - 2021-05-21
1922

2023
### Added

b2sdk/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def get_download_url_for_file_name(self, bucket_name, file_name):
434434
:param str bucket_name: a bucket name
435435
:param str file_name: a file name
436436
"""
437-
self.check_bucket_restrictions(bucket_name)
437+
self.check_bucket_name_restrictions(bucket_name)
438438
return '%s/file/%s/%s' % (
439439
self.account_info.get_download_url(), bucket_name, b2_url_encode(file_name)
440440
)

test/unit/v_all/test_api.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,17 @@ def test_get_bucket_by_id_v2(self):
6161
self.cache.save_bucket(Bucket(api=self.api, name='bucket_name', id_='bucket_id'))
6262
read_bucket = self.api.get_bucket_by_id('bucket_id')
6363
assert read_bucket.name == 'bucket_name'
64+
65+
def test_get_download_url_for_file_name(self):
66+
self._authorize_account()
67+
68+
download_url = self.api.get_download_url_for_file_name('bucket1', 'some-file.txt')
69+
70+
assert download_url == 'http://download.example.com/file/bucket1/some-file.txt'
71+
72+
def test_get_download_url_for_fileid(self):
73+
self._authorize_account()
74+
75+
download_url = self.api.get_download_url_for_fileid('file-id')
76+
77+
assert download_url == 'http://download.example.com/b2api/v2/b2_download_file_by_id?fileId=file-id'

0 commit comments

Comments
 (0)