Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ def storage_blob_upload_batch(cmd, client, source, destination, pattern=None, #
maxsize_condition=None, max_connections=2, lease_id=None, progress_callback=None,
if_modified_since=None, if_unmodified_since=None, if_match=None,
if_none_match=None, timeout=None, dryrun=False, socket_timeout=None, **kwargs):
def _create_return_result(blob_content_settings, upload_result=None):
def _create_return_result(blob_content_settings, blob_client, upload_result=None):
return {
'Blob': client.url,
'Blob': blob_client.url,
'Type': blob_content_settings.content_type,
'Last Modified': upload_result['last_modified'] if upload_result else None,
'eTag': upload_result['etag'] if upload_result else None}
Expand All @@ -434,8 +434,11 @@ def _create_return_result(blob_content_settings, upload_result=None):
logger.info(' total %d', len(source_files))
results = []
for src, dst in source_files:
blob_client = client.get_blob_client(container=destination_container_name,
blob=normalize_blob_file_path(destination_path, dst))
results.append(_create_return_result(blob_content_settings=guess_content_type(src, content_settings,
t_content_settings)))
t_content_settings),
blob_client=blob_client))
else:
@check_precondition_success
def _upload_blob(*args, **kwargs):
Expand Down Expand Up @@ -467,7 +470,7 @@ def _upload_blob(*args, **kwargs):
if_none_match=if_none_match, timeout=timeout, **kwargs)
if include:
results.append(_create_return_result(blob_content_settings=guessed_content_settings,
upload_result=result))
blob_client=blob_client, upload_result=result))
except (ResourceModifiedError, AzureResponseError) as ex:
logger.error(ex)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def test_storage_blob_batch_upload_scenarios(self, test_dir, storage_account_inf
self.storage_cmd('storage blob list -c {} --prefix some_dir',
storage_account_info, container).assert_with_checks(JMESPathCheck('length(@)', 4))

# upload-batch with preconditon
container = self.create_container(storage_account_info)
self.storage_cmd('storage blob upload-batch -d {} -s "{}"',
storage_account_info, container, test_dir)
import time
Expand All @@ -142,6 +144,19 @@ def test_storage_blob_batch_upload_scenarios(self, test_dir, storage_account_inf
container, test_dir, current).get_output_in_json()
self.assertEqual(len(result), 41)

#check result url
container = self.create_container(storage_account_info)
result = self.storage_cmd('storage blob upload-batch -s "{}" -d {}', storage_account_info,
test_dir, container).get_output_in_json()
if result and result[0]:
res = result[0]
self.assertRegex(res['Blob'], '^.*[^\/]+$')
base_url = res['Blob'].split('/')[:3]
container = res['Blob'].split('/')[3]
blob_name = '/'.join(res['Blob'].split('/')[4:])
self.storage_cmd('storage blob show -c {} -n {}', storage_account_info,
container, blob_name)

@ResourceGroupPreparer()
@StorageAccountPreparer()
@StorageTestFilesPreparer()
Expand Down