def _download_blob(blob_service, container, destination_folder, blob_name): # TODO: try catch IO exception destination_path = os.path.join(destination_folder, blob_name) destination_folder = os.path.dirname(destination_path) if not os.path.exists(destination_folder): mkdir_p(destination_folder) blob = blob_service.get_blob_to_path(container, blob_name, destination_path) return blob.name
def _download_blob(blob_service, container, destination_folder, blob_name): # TODO: try catch IO exception destination_path = os.path.join(destination_folder, blob_name) destination_folder = os.path.dirname(destination_path) if not os.path.exists(destination_folder): mkdir_p(destination_folder) blob = blob_service.get_blob_to_path(container, blob_name, destination_path) return blob.name
def _download_blob(blob_service, container, destination_folder, normalized_blob_name, blob_name): # TODO: try catch IO exception destination_path = os.path.join(destination_folder, normalized_blob_name) destination_folder = os.path.dirname(destination_path) if not os.path.exists(destination_folder): mkdir_p(destination_folder) blob = blob_service.get_blob_to_path(container, blob_name, destination_path, max_connections=max_connections, progress_callback=progress_callback) return blob.name
def _download_blob(blob_service, container, destination_folder, normalized_blob_name, blob_name): # TODO: try catch IO exception destination_path = os.path.join(destination_folder, normalized_blob_name) destination_folder = os.path.dirname(destination_path) if not os.path.exists(destination_folder): mkdir_p(destination_folder) blob = blob_service.get_blob_to_path(container, blob_name, destination_path, max_connections=max_connections, progress_callback=progress_callback) return blob.name
def _download_action(pair): destination_dir = os.path.join(destination, pair[0]) mkdir_p(destination_dir) get_file_args = {'share_name': source, 'directory_name': pair[0], 'file_name': pair[1], 'file_path': os.path.join(destination, *pair), 'max_connections': max_connections, 'progress_callback': progress_callback, 'snapshot': snapshot} if cmd.supported_api_version(min_api='2016-05-31'): get_file_args['validate_content'] = validate_content client.get_file_to_path(**get_file_args) return client.make_file_url(source, *pair)
def _download_action(pair): destination_dir = os.path.join(destination, pair[0]) mkdir_p(destination_dir) get_file_args = {'share_name': source, 'directory_name': pair[0], 'file_name': pair[1], 'file_path': os.path.join(destination, *pair), 'max_connections': max_connections, 'progress_callback': progress_callback} if cmd.supported_api_version(min_api='2016-05-31'): get_file_args['validate_content'] = validate_content client.get_file_to_path(**get_file_args) return client.make_file_url(source, *pair)
def download_file(client, destination_path=None, overwrite=True, timeout=None): destination_folder = os.path.dirname( destination_path) if destination_path else "" if destination_folder and not os.path.exists(destination_folder): mkdir_p(destination_folder) if not destination_folder or os.path.isdir(destination_path): file = client.get_file_properties(timeout=timeout) file_name = file.name.split("/")[-1] destination_path = os.path.join(destination_path, file_name) \ if destination_path else file_name if not overwrite and os.path.exists(destination_path): raise CLIError( 'The specified path already exists. Please change to a valid path. ' ) with open(destination_path, 'wb') as stream: download = client.download_file(timeout=timeout) download_content = download.readall() stream.write(download_content)