Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storage] az storage blob/file update: Fix --content-md5 TypeError #23253

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/azure-cli/azure/cli/command_modules/storage/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.register_blob_arguments()
c.register_precondition_options()
t_blob_content_settings = self.get_sdk('_models#ContentSettings', resource_type=ResourceType.DATA_STORAGE_BLOB)
c.register_content_settings_argument(t_blob_content_settings, update=True)
c.register_content_settings_argument(t_blob_content_settings, update=True, process_md5=True)
c.extra('lease', options_list=['--lease-id'], help='Required if the blob has an active lease.')

with self.argument_context('storage blob exists') as c:
Expand Down Expand Up @@ -1948,7 +1948,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
resource_type=ResourceType.DATA_STORAGE_FILESHARE)
c.extra('share_name', share_name_type, required=True)
c.register_path_argument()
c.register_content_settings_argument(t_file_content_settings, update=True)
c.register_content_settings_argument(t_file_content_settings, update=True, process_md5=True)
c.extra('timeout', help='Request timeout in seconds. Applies to each call to the service.', type=int)

with self.argument_context('storage file upload') as c:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,10 @@ def validator(cmd, namespace):
# content_md5 value to bytearray. And track2 SDK will serialize it into the right value with str type in header.
if is_storagev2(prefix):
if process_md5 and new_props.content_md5:
from .track2_util import _str_to_bytearray
new_props.content_md5 = _str_to_bytearray(new_props.content_md5)
# During update, the content_md5 might be bytearray, we do not need to convert again.
if not isinstance(new_props.content_md5, bytearray):
from .track2_util import _str_to_bytearray
new_props.content_md5 = _str_to_bytearray(new_props.content_md5)

ns['content_settings'] = new_props

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@ interactions:
- request:
body: null
headers:
Accept:
- application/xml
Accept-Encoding:
- gzip, deflate
CommandName:
- storage container create
Connection:
- keep-alive
Content-Length:
- '0'
ParameterSetName:
- -n --account-name --account-key
User-Agent:
- Azure-Storage/2.0.0-2.0.1 (Python CPython 3.9.6; Windows 10) AZURECLI/2.34.1
- AZURECLI/2.38.0 azsdk-python-storage-blob/12.12.0 Python/3.10.5 (Windows-10-10.0.22000-SP0)
x-ms-date:
- Fri, 04 Mar 2022 08:01:40 GMT
- Tue, 19 Jul 2022 03:23:09 GMT
x-ms-version:
- '2018-11-09'
- '2021-06-08'
method: PUT
uri: https://clitest000002.blob.core.windows.net/con000003?restype=container
response:
Expand All @@ -21,15 +29,15 @@ interactions:
content-length:
- '0'
date:
- Fri, 04 Mar 2022 08:01:42 GMT
- Tue, 19 Jul 2022 03:23:10 GMT
etag:
- '"0x8D9FDB5381751C6"'
- '"0x8DA6936021DDEF9"'
last-modified:
- Fri, 04 Mar 2022 08:01:42 GMT
- Tue, 19 Jul 2022 03:23:11 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-version:
- '2018-11-09'
- '2021-06-08'
status:
code: 201
message: Created
Expand All @@ -53,15 +61,15 @@ interactions:
ParameterSetName:
- -c -f -n --content-md5 --account-name --account-key
User-Agent:
- AZURECLI/2.34.1 azsdk-python-storage-blob/12.9.0 Python/3.9.6 (Windows-10-10.0.19044-SP0)
- AZURECLI/2.38.0 azsdk-python-storage-blob/12.12.0 Python/3.10.5 (Windows-10-10.0.22000-SP0)
x-ms-blob-content-md5:
- DfvoqkwgtS4bi/PLbL3xkw==
x-ms-blob-type:
- BlockBlob
x-ms-date:
- Fri, 04 Mar 2022 08:01:41 GMT
- Tue, 19 Jul 2022 03:23:10 GMT
x-ms-version:
- '2020-10-02'
- '2021-06-08'
method: PUT
uri: https://clitest000002.blob.core.windows.net/con000003/blob000004
response:
Expand All @@ -73,20 +81,122 @@ interactions:
content-md5:
- DfvoqkwgtS4bi/PLbL3xkw==
date:
- Fri, 04 Mar 2022 08:01:43 GMT
- Tue, 19 Jul 2022 03:23:12 GMT
etag:
- '"0x8D9FDB53925D7BE"'
- '"0x8DA693603396274"'
last-modified:
- Fri, 04 Mar 2022 08:01:43 GMT
- Tue, 19 Jul 2022 03:23:12 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-content-crc64:
- UNjdat8Fk3M=
x-ms-request-server-encrypted:
- 'true'
x-ms-version:
- '2020-10-02'
- '2021-06-08'
status:
code: 201
message: Created
- request:
body: null
headers:
Accept:
- application/xml
Accept-Encoding:
- gzip, deflate
CommandName:
- storage blob update
Connection:
- keep-alive
ParameterSetName:
- -c -n --content-md5 --account-name --account-key
User-Agent:
- AZURECLI/2.38.0 azsdk-python-storage-blob/12.12.0 Python/3.10.5 (Windows-10-10.0.22000-SP0)
x-ms-date:
- Tue, 19 Jul 2022 03:23:12 GMT
x-ms-version:
- '2021-06-08'
method: HEAD
uri: https://clitest000002.blob.core.windows.net/con000003/blob000004
response:
body:
string: ''
headers:
accept-ranges:
- bytes
content-length:
- '131072'
content-md5:
- DfvoqkwgtS4bi/PLbL3xkw==
content-type:
- application/octet-stream
date:
- Tue, 19 Jul 2022 03:23:13 GMT
etag:
- '"0x8DA693603396274"'
last-modified:
- Tue, 19 Jul 2022 03:23:12 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-blob-type:
- BlockBlob
x-ms-creation-time:
- Tue, 19 Jul 2022 03:23:12 GMT
x-ms-lease-state:
- available
x-ms-lease-status:
- unlocked
x-ms-server-encrypted:
- 'true'
x-ms-version:
- '2021-06-08'
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/xml
Accept-Encoding:
- gzip, deflate
CommandName:
- storage blob update
Connection:
- keep-alive
Content-Length:
- '0'
ParameterSetName:
- -c -n --content-md5 --account-name --account-key
User-Agent:
- AZURECLI/2.38.0 azsdk-python-storage-blob/12.12.0 Python/3.10.5 (Windows-10-10.0.22000-SP0)
x-ms-blob-content-md5:
- '0000'
x-ms-blob-content-type:
- application/octet-stream
x-ms-date:
- Tue, 19 Jul 2022 03:23:13 GMT
x-ms-version:
- '2021-06-08'
method: PUT
uri: https://clitest000002.blob.core.windows.net/con000003/blob000004?comp=properties
response:
body:
string: ''
headers:
content-length:
- '0'
date:
- Tue, 19 Jul 2022 03:23:14 GMT
etag:
- '"0x8DA693604870DA8"'
last-modified:
- Tue, 19 Jul 2022 03:23:15 GMT
server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-version:
- '2021-06-08'
status:
code: 200
message: OK
version: 1
Loading