如何在 Bing 广告 API 中获取 CSV 作为字符串或流

How to get a CSV as a string or stream in Bing Ads API

我正在使用 Bing 广告 API 为使用来自 nuget 的 Microsoft.BingAds.SDK 的客户创建在线广告效果仪表板。

现在一切正常,但我必须先将 csv 报告下载到文件系统,然后才能读取数据并将其显示给用户:

            var t = await manager.DownloadFileAsync(
                new ReportingDownloadParameters()
                {
                    ReportRequest = request,
                    OverwriteResultFile = true,
                    ResultFileDirectory = @"C:\Temp",
                    ResultFileName = @"GL15.csv",
                });

            var csvConfig = new CsvHelper.Configuration.CsvConfiguration()
            {
                Delimiter = ",",
                HasHeaderRecord = true,
                Quote = '"'
            };

            var returnList = new List<BingDailyCampaignPerformance>();

            using (var textReader = System.IO.File.OpenText(@"C:\Temp\GL15.csv"))
            using (var csvReader = new CsvHelper.CsvReader(textReader, csvConfig))
            {
                while (csvReader.Read())
                {
                    returnList.Add(GetRow(csvReader));
                }
            }

这似乎效率不高 - 为什么我不能以某种方式将 csv 下载到内存,并跳过文件系统?

有没有可能做到这一点?

使用 BulkServiceManager 可以选择 read entities directly via temp memory, but currently ReportingServiceManager only supports file download as you noted. Similar to the Bulk download experience we are tracking the "ReportFileReader" feature request, although there isn't yet any firm ETA. Please feel free to add to the Bing Ads Feature Suggestions