简体   繁体   English

GetBlockBlobReference无法使用绝对文件路径

[英]GetBlockBlobReference is not working with absolute file path

I have stored my file in azure storage and later on trying to read that file using below code. 我已将文件存储在azure存储中,以后尝试使用下面的代码读取该文件。 But it is giving an error 404 not found when I am giving the full file path like this " https://appsdemostore.blob.core.windows.net/content/82b159f4-6730-432d-b061-05cf0cdfa16d.txt ". 但是当我给出这样的完整文件路径时,它给出的错误404找不到“ https://appsdemostore.blob.core.windows.net/content/82b159f4-6730-432d-b061-05cf0cdfa16d.txt ”。 But when I am giving filepath as this "82b159f4-6730-432d-b061-05cf0cdfa16d.txt" it is working.I am facing this issue after upgrading the library.Is there any way to work the code with full fule path. 但是,当我将文件路径指定为“ 82b159f4-6730-432d-b061-05cf0cdfa16d.txt”时,它正在运行。升级库后,我遇到了这个问题。有没有办法使用完整文件路径来处理代码。 Because in my database they are stored as full file path. 因为它们在我的数据库中存储为完整文件路径。

  CloudBlockBlob blockBlob = container.GetBlockBlobReference(filePath);

                return blockBlob.DownloadText();

Assuming you already have storage credentials (account name/key), you could do the following: 假设您已经具有存储凭据(帐户名称/密钥),则可以执行以下操作:

        var credentials = new StorageCredentials("account-name", "account-key");
        var blob = new CloudBlockBlob(new Uri(filePath), credentials);
        blob.DownloadText();

You just need to give the file name not the whole path. 您只需要提供文件名而不是整个路径即可。

CloudBlockBlob blockBlob = container.GetBlockBlobReference("82b159f4-6730-
                                           432d-b061-05cf0cdfa16d.txt");

            return blockBlob.DownloadText();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM