from azure.storage.file import FileService
from azure.storage import CloudStorageAccount
from azure.storage.file import ContentSettings
import azure.common
account_name ='muthuselvan3storage'
account_key = 'f2J7qn5vNrcfnYedWeK9QLEeWhNtVEjWSV+syakafhJSKyMP2wYVrP5lIZDvv7bwmYmoCQKnVsXfL51Oblte4A=='
account = CloudStorageAccount(account_name, account_key)
file_service = account.create_file_service()


#https://docs.microsoft.com/en-us/azure/storage/storage-python-how-to-use-file-storage
def upload():
    file_service.create_file_from_path(
        'java',
        None, # We want to create this blob in the root directory, so we specify None for the directory_name
        'xen-automation-testcode-2.0.jar', # remote file name
        'xen-automation-testcode-1.0.jar', # local file name
        content_settings=ContentSettings(content_type='image/png'))


def download():
    generator = file_service.list_directories_and_files('java')
    for file_or_dir in generator:
        print(file_or_dir.name)

    shares =  file_service.list_shares()
    for share in shares:
        print('  Share name:' + share.name)

    file_service.get_file_to_path(
                'java',              # share name
                 None,          # directory path
                'java.png',               # source file name
                'azure_local_storage/java.png')       # destinatation path with name




if __name__ == '__main__':
    # download()
    upload()



#https://azure-sdk-for-python.readthedocs.io/en/latest/
#https://docs.microsoft.com/en-us/azure/storage/storage-python-how-to-use-file-storage
#generator = file_service.list_directories_and_files('java')
#for file_or_dir in generator:
 #   print(file_or_dir.name)

#https://github.com/Azure-Samples/storage-file-python-getting-started/blob/master/start.py

#https://github.com/Azure-Samples/storage-file-python-getting-started
