4
4
# --------------------------------------------------------------------------------------------
5
5
6
6
import os
7
+ import sys
7
8
from datetime import datetime
8
9
9
10
from azure .cli .core .profiles import ResourceType , get_sdk
@@ -529,7 +530,6 @@ def transform_blob_type(cmd, blob_type):
529
530
def _adjust_block_blob_size (client , blob_type , length ):
530
531
if not blob_type or blob_type != 'block' or length is None :
531
532
return
532
-
533
533
# increase the block size to 100MB when the block list will contain more than 50,000 blocks(each block 4MB)
534
534
if length > 50000 * 4 * 1024 * 1024 :
535
535
client ._config .max_block_size = 100 * 1024 * 1024
@@ -623,7 +623,7 @@ def upload_blob(cmd, client, file_path=None, container_name=None, blob_name=None
623
623
return response
624
624
625
625
626
- def download_blob (client , file_path , open_mode = 'wb' , start_range = None , end_range = None ,
626
+ def download_blob (client , file_path = None , open_mode = 'wb' , start_range = None , end_range = None ,
627
627
progress_callback = None , ** kwargs ):
628
628
offset = None
629
629
length = None
@@ -632,11 +632,16 @@ def download_blob(client, file_path, open_mode='wb', start_range=None, end_range
632
632
length = end_range - start_range + 1
633
633
if progress_callback :
634
634
kwargs ['raw_response_hook' ] = progress_callback
635
+ if not file_path :
636
+ kwargs ['max_concurrency' ] = 1
635
637
download_stream = client .download_blob (offset = offset , length = length , ** kwargs )
636
- with open (file_path , open_mode ) as stream :
638
+ if file_path :
639
+ with open (file_path , open_mode ) as stream :
640
+ download_stream .readinto (stream )
641
+ return download_stream .properties
642
+ with os .fdopen (sys .stdout .fileno (), open_mode ) as stream :
637
643
download_stream .readinto (stream )
638
-
639
- return download_stream .properties
644
+ return
640
645
641
646
642
647
def get_block_ids (content_length , block_length ):
0 commit comments