Azure 使用 Blob 存储索引器在元数据中搜索无效的 base64 路径

Azure Search invalid base64 path in metadata using Blob Storage Indexer

我使用 Blob 存储索引器在 Azure 搜索中为我的文件编制索引。

执行搜索后,我应该能够通过解码 base64 元数据字符串来确定 blob 的路径。据我所知,C# 无法解码返回的 base64。

以下是从 Azure 搜索发送的示例 base64 路径:

1. aHR0cHM6Ly9qbG9jYWxnZW5lcmFsLmJsb2IuY29yZS53aW5kb3dzLm5ldC9kaWFyaW9zLzEvMTAtdGV4dG8uemlw0 -> 当我尝试在 C# 中对其进行解码时,出现以下异常:"Invalid length for a Base-64 char array or string."

2.
aHR0cHM6Ly9qbG9jYWxnZW5lcmFsLmJsb2IuY29yZS53aW5kb3dzLm5ldC9kaWFyaW9zLzEvMi10ZXh0by56aXA1 -> 在末尾添加一个 5,它不在原始路径中

3. aHR0cHM6Ly9qbG9jYWxnZW5lcmFsLmJsb2IuY29yZS53aW5kb3dzLm5ldC9kaWFyaW9zLzEvMy10ZXh0by56aXA1 -> 在末尾添加一个 5,它不在原始路径中

这是我用来解码的代码:

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

请参考 documenation. Specifically, you need to use UrlTokenDecode method 或同等内容。