Python Forum

Full Version: getting [Errno 13] Permission denied:
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
from azure.storage.blob import BlockBlobService
from azure.storage.blob import PublicAccess
import os

def run_sample():
    try:

        block_blob_service = BlockBlobService(account_name='***',
                                              account_key='***')

        container_name = "test"
        block_blob_service.create_container(container_name)
        print('container created')
        block_blob_service.set_container_acl(container_name, public_access=PublicAccess.Container)
        print('public access provided')
        full = "D:"
        os.chdir(full)
        print(os.getcwd())
        full_na = 'demo1'
        os.chdir(full_na)
        print(os.getcwd())

        print('entered into path')
        files = os.listdir(full)
        for name in files:
            print(name)
            block_blob_service.create_blob_from_path(container_name, files, file_path=os.getcwd())

    except Exception as e:
        print(e)

# Main method.
if __name__ == '__main__':
    run_sample()
Output:
I'm getting this error: container created public access provided D:\ D:\demo1 entered into path stderr [Errno 13] Permission denied: 'D:\\demo1' Process finished with exit code 0
Question
I need to upload the files to azure blob storage from folder demo1 in 'D' Drive
It's telling you that you don't have access to directory demo1 on D:
or, it's also possible that the directory doesn't exist

**Note** You can make the directory manipulation much cleaner by using pathlib.