Skip to content

Commit 07adf1b

Browse files
committed
URL fixes
1 parent 4bf1e44 commit 07adf1b

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

azure-storage-blob/azure/storage/blob/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# license information.
55
# --------------------------------------------------------------------------
66

7-
__version__ = "3.0.0a6"
7+
__version__ = "3.0.0a8"
88

99
from .common import BlobType
1010
from .blob_client import BlobClient

azure-storage-blob/azure/storage/blob/aio/blob_client_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ async def create_snapshot(
114114
:returns: SnapshotProperties
115115
"""
116116

117-
async def copy_blob_from_source(
118-
self, copy_source, metadata=None, source_if_modified_since=None,
117+
async def copy_blob_from_url(
118+
self, source_url, metadata=None, source_if_modified_since=None,
119119
source_if_unmodified_since=None, source_if_match=None, source_if_none_match=None,
120120
destination_if_modified_since=None, destination_if_unmodified_since=None,
121121
destination_if_match=None, destination_if_none_match=None, destination_lease=None,

azure-storage-blob/azure/storage/blob/blob_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def __init__(
100100
:param configuration: A optional pipeline configuration.
101101
This can be retrieved with :func:`BlobClient.create_configuration()`
102102
"""
103-
parsed_url = urlparse(url)
103+
parsed_url = urlparse(url.rstrip('/'))
104104

105105
if not parsed_url.path and not (container and blob):
106106
raise ValueError("Please specify a container and blob name.")
@@ -497,7 +497,7 @@ def upload_blob(
497497
raise ValueError("A content length must be specified for a Page Blob.")
498498
if length % 512 != 0:
499499
raise ValueError("Invalid page blob size: {0}. "
500-
"The size must be aligned to a 512-byte boundary.".format(count))
500+
"The size must be aligned to a 512-byte boundary.".format(length))
501501
if premium_page_blob_tier:
502502
try:
503503
headers['x-ms-access-tier'] = premium_page_blob_tier.value
@@ -554,9 +554,9 @@ def download_blob(
554554
):
555555
# type: (...) -> Iterable[bytes]
556556
"""
557-
TODO: Full download chunking needed.
558557
:returns: A iterable data generator (stream)
559558
"""
559+
# TODO: Full download chunking needed.
560560
access_conditions = get_access_conditions(lease)
561561
mod_conditions = get_modification_conditions(
562562
if_modified_since, if_unmodified_since, if_match, if_none_match)
@@ -986,8 +986,8 @@ def create_snapshot(
986986
snapshot.blob_type = self.blob_type
987987
return snapshot
988988

989-
def copy_blob_from_source(
990-
self, copy_source, # type: str
989+
def copy_blob_from_url(
990+
self, source_url, # type: str
991991
metadata=None, # type: Optional[Dict[str, str]]
992992
source_if_modified_since=None, # type: Optional[datetime]
993993
source_if_unmodified_since=None, # type: Optional[datetime]
@@ -1035,7 +1035,7 @@ def copy_blob_from_source(
10351035
to check the status of the copy operation, or wait() to block until the
10361036
operation is complete. The final blob will be committed when the copy completes.
10371037
1038-
:param str copy_source:
1038+
:param str source_url:
10391039
A URL of up to 2 KB in length that specifies an Azure file or blob.
10401040
The value should be URL-encoded as it would appear in a request URI.
10411041
If the source is in another account, the source must either be public

azure-storage-blob/azure/storage/blob/blob_service_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@
5656
class BlobServiceClient(object):
5757

5858
def __init__(
59-
self, url, # type: str
59+
self, account_url, # type: str
6060
credentials=None, # type: Optional[HTTPPolicy]
6161
configuration=None, # type: Optional[Configuration]
6262
**kwargs # type: Any
6363
):
6464
# type: (...) -> None
65-
parsed_url = urlparse(url)
65+
parsed_url = urlparse(account_url.rstrip('/'))
6666
self.scheme = parsed_url.scheme
6767
self.account = parsed_url.hostname.split(".blob.core.")[0]
6868
self.credentials = credentials
69-
self.url = url if not parsed_url.path else "{}://{}".format(
69+
self.url = account_url if not parsed_url.path else "{}://{}".format(
7070
self.scheme,
7171
parsed_url.hostname
7272
)

azure-storage-blob/azure/storage/blob/container_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(
7575
:param configuration: A optional pipeline configuration.
7676
This can be retrieved with :func:`ContainerClient.create_configuration()`
7777
"""
78-
parsed_url = urlparse(url)
78+
parsed_url = urlparse(url.rstrip('/'))
7979

8080
if not parsed_url.path and not container:
8181
raise ValueError("Please specify a container name.")
@@ -486,7 +486,7 @@ def list_blob_properties(self, starts_with=None, include=None, timeout=None, **k
486486
include=include,
487487
timeout=timeout,
488488
**kwargs)
489-
return BlobPropertiesPaged(command, prefix=prefix, results_per_page=results_per_page, marker=marker)
489+
return BlobPropertiesPaged(command, prefix=starts_with, results_per_page=results_per_page, marker=marker)
490490

491491
# def walk_blob_propertes(self, prefix=None, include=None, delimiter="/", timeout=None, **kwargs):
492492
# # type: (Optional[str], Optional[str], str, Optional[int]) -> Iterable[BlobProperties]

azure-storage-blob/tests/blob/test_common_blob.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ def test_copy_blob_with_existing_blob(self):
935935

936936
source_blob = "http://www.gutenberg.org/files/59466/59466-0.txt"
937937
copied_blob = self.bsc.get_blob_client(self.container_name, '59466-0.txt')
938-
copy = copied_blob.copy_blob_from_source(source_blob)
938+
copy = copied_blob.copy_blob_from_url(source_blob)
939939
self.assertEqual(copy.status(), 'pending')
940940
copy.wait()
941941

@@ -959,7 +959,7 @@ def test_copy_blob_async_private_blob(self):
959959
target_blob_name = 'targetblob'
960960
with self.assertRaises(ResourceNotFoundError):
961961
target_blob = self.bsc.get_blob_client(self.container_name, target_blob_name)
962-
target_blob.copy_blob_from_source(source_blob_url)
962+
target_blob.copy_blob_from_url(source_blob_url)
963963

964964
# Assert
965965

@@ -982,7 +982,7 @@ def test_copy_blob_async_private_blob_with_sas(self):
982982
# Act
983983
target_blob_name = 'targetblob'
984984
target_blob = self.bsc.get_blob_client(self.container_name, target_blob_name)
985-
copy_resp = target_blob.copy_blob_from_source(source_blob_url)
985+
copy_resp = target_blob.copy_blob_from_url(source_blob_url)
986986

987987
# Assert
988988
#self.assertEqual(copy_resp.status(), 'pending')
@@ -1011,7 +1011,7 @@ def test_abort_copy_blob(self):
10111011
# Act
10121012
target_blob_name = 'targetblob'
10131013
target_blob = self.bsc.get_blob_client(self.container_name, target_blob_name)
1014-
copy_resp = target_blob.copy_blob_from_source(source_blob_url)
1014+
copy_resp = target_blob.copy_blob_from_url(source_blob_url)
10151015

10161016
#self.assertEqual(copy_resp.status(), 'pending')
10171017
copy_resp.abort()

sdk/core/azure-core/azure/core/pipeline_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _request(self, method, url, params, headers, content, form_content, stream_c
113113

114114
if form_content:
115115
request.set_formdata_body(form_content)
116-
elif stream_content:
116+
elif stream_content is not None:
117117
request.set_streamed_data_body(stream_content)
118118

119119
return request

sdk/core/azure-core/azure/core/pipeline_client_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _request(self, method, url, params, headers, content, form_content, stream_c
102102

103103
if form_content:
104104
request.set_formdata_body(form_content)
105-
elif stream_content:
105+
elif stream_content is not None:
106106
request.set_streamed_data_body(stream_content)
107107

108108
return request

0 commit comments

Comments
 (0)