Skip to content

Commit

Permalink
Merge pull request #253 from ehossack/fix/bucket-name-restrictions
Browse files Browse the repository at this point in the history
Fix an issue calling incorrect api
  • Loading branch information
ppolewicz authored May 31, 2021
2 parents cf16a08 + 8fe7a35 commit de26adf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Refactored `FileVersionInfo` to `FileVersion`
* `ScanPoliciesManager` exclusion interface changed

### Fixed
* Fix call to incorrect internal api in `B2Api.get_download_url_for_file_name`

## [1.8.0] - 2021-05-21

### Added
Expand Down
2 changes: 1 addition & 1 deletion b2sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def get_download_url_for_file_name(self, bucket_name, file_name):
:param str bucket_name: a bucket name
:param str file_name: a file name
"""
self.check_bucket_restrictions(bucket_name)
self.check_bucket_name_restrictions(bucket_name)
return '%s/file/%s/%s' % (
self.account_info.get_download_url(), bucket_name, b2_url_encode(file_name)
)
Expand Down
14 changes: 14 additions & 0 deletions test/unit/v_all/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,17 @@ def test_get_bucket_by_id_v2(self):
self.cache.save_bucket(Bucket(api=self.api, name='bucket_name', id_='bucket_id'))
read_bucket = self.api.get_bucket_by_id('bucket_id')
assert read_bucket.name == 'bucket_name'

def test_get_download_url_for_file_name(self):
self._authorize_account()

download_url = self.api.get_download_url_for_file_name('bucket1', 'some-file.txt')

assert download_url == 'http://download.example.com/file/bucket1/some-file.txt'

def test_get_download_url_for_fileid(self):
self._authorize_account()

download_url = self.api.get_download_url_for_fileid('file-id')

assert download_url == 'http://download.example.com/b2api/v2/b2_download_file_by_id?fileId=file-id'

0 comments on commit de26adf

Please sign in to comment.