0

I'm using the Bing Ads API to create an online advertising performance dashboard for a customer using the Microsoft.BingAds.SDK from nuget.

Right now stuff works, but I'm having to download the csv report to the file system before reading the data and showing it to the user:

            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));
                }
            }

This seems less than efficient - why can't I just download the csv to memory in some way, and skip the file system?

Is there a possibility to do this?

Menno van den Heuvel
  • 1,851
  • 13
  • 24

1 Answers1

0

With the BulkServiceManager there is an option to 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.

Eric Urban
  • 582
  • 2
  • 7
  • 1
    Thanks for confirming I'm not crazy. For the life of me I can't imagine why the design decision was made to always save to disk, instead of passing around streams. ILSpy shows me it's file paths all the way down in the DLL as well. Poor Bing Ads API SDK developers. – Menno van den Heuvel May 15 '18 at 09:48