Can't access the blob file in sub directory

感情迁移 提交于 2019-12-13 05:47:21

问题


There is no sub container(directory) in Azure blob storage. I simply use slashes in file name for having virtual sub directory.

here is example.

http://apolyonstorage.blob.core.windows.net/banners/Local/Homepage/index.html

Container Name: banners

File Name : Local/Homepage/index.html

I upload the file and access it on Azure portal but simply accessing the link fail by telling resource is not found but it is actually exist.

Why it fails when i access it on browser by link ?


回答1:


What's the ACL on the blob container? For a blob to be accessible directly via URL (or in other words anonymous access, blob container's ACL should be either Blob or Public.

You can use the sample code below to change the container's ACL:

        CloudStorageAccount account = new CloudStorageAccount(new StorageCredentials(StorageAccount, StorageAccountKey), true);
        CloudBlobClient blobClient = account.CreateCloudBlobClient();
        var container = blobClient.GetContainerReference("your-container-name");
        BlobContainerPermissions permissions = new BlobContainerPermissions()
        {
            PublicAccess = BlobContainerPublicAccessType.Blob,//Or BlobContainerPublicAccessType.Container
        };
        container.SetPermissions(permissions);


来源:https://stackoverflow.com/questions/28265149/cant-access-the-blob-file-in-sub-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!