简体   繁体   中英

Azure Search invalid base64 path in metadata using Blob Storage Indexer

I used Blob Storage Indexer to index my files in Azure Search.

After performing a search, I was supposed to be able to determine the path of blob by decoding a base64 metadata string. From what I can tell, C# is unable to decode the returned base64.

Here are sample base64 paths sent from Azure Search:

1. aHR0cHM6Ly9qbG9jYWxnZW5lcmFsLmJsb2IuY29yZS53aW5kb3dzLm5ldC9kaWFyaW9zLzEvMTAtdGV4dG8uemlw0 -> When I try to decode it in C#, I get the following exception: "Invalid length for a Base-64 char array or string." Code used is bellow

2.
aHR0cHM6Ly9qbG9jYWxnZW5lcmFsLmJsb2IuY29yZS53aW5kb3dzLm5ldC9kaWFyaW9zLzEvMi10ZXh0by56aXA1 -> adds a 5 to the end, that is not in the original path

3. aHR0cHM6Ly9qbG9jYWxnZW5lcmFsLmJsb2IuY29yZS53aW5kb3dzLm5ldC9kaWFyaW9zLzEvMy10ZXh0by56aXA1 -> adds a 5 to the end, that is not in the original path

Here is the code I am using to decode it:

    public static string DecodeBase64(this string base64)
    {
        // I have also tried with ASCII
        return System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(base64));
    }

在此处输入图片说明

Please refer to the documenation . Specifically, you need to use UrlTokenDecode method or an equivalent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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