question

Upvotes
Accepted
22 0 1 4

C# SDK - Support for AWS downloads

Hello,

we are using the C# SDK and we were wondering if there are any plans to introduce the ability to get TRTH results over AWS as announced in the TRTH release notes 11.1.5.5

Thanks

tick-history-rest-apirest-apic#
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Hi Oliver!

Yes it did work in the end. Thanks all for the support

BR

Giovanni

Upvote
Accepted
13.7k 26 8 12

@Giovanni.Condello, it is possible to do that using the C# SDK.

In the code you must set the x-direct-download header, it would look somewhat like this:

var context = new StandardExtractionsContext(new
Uri("https://hosted.datascopeapi.reuters.com/RestApi/v1/"), "<your user id>", "<your password>");
context.DefaultRequestHeaders.Add("x-direct-download", "true");
var stream = context.UserPackageDeliveryOperations.GetReadStream("<packageDeliveryId>");
// Read Stream here…

I have not yet tried this, but will attempt to make a sample in a near future, which I'll make available for download when available.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

@Giovanni.Condello

You can also use the following code to set the X-Direct-Download header. This will set the header once for a next API call.

Func<System.Collections.Generic.Dictionary<string, string>> directDownload = delegate()
{
    System.Collections.Generic.Dictionary<string, string> header = new System.Collections.Generic.Dictionary<string, string>();
    header.Add("X-Direct-Download", "true");
    return header;
};

ExtractionsContext.SetRequestHeaders(directDownload);

using (var response = ExtractionsContext.RawExtractionResultOperations.GetReadStream(result))

@Giovanni.Condello, here is a tested code snippet:

//Set header for direct download from AWS:
extractionsContext.DefaultRequestHeaders.Add("x-direct-download", "true");
//Save data stream to file:
DssStreamResponse streamResponse = extractionsContext.GetReadStream(extractionResult);
using (var fileStream = File.Create(dataOutputFile))
    streamResponse.Stream.CopyTo(fileStream);
//Reset header after direct download from AWS:
extractionsContext.DefaultRequestHeaders.Remove("x-direct-download");

Hope this helps. I will soon update the C# samples and tutorials to include AWS downloads.

@Giovanni.Condello, the TRTH C# code samples and C# Tutorials 2 (VBD), 4 (scheduled extraction) and 5 (On Demand extraction) have been updated to allow use of AWS.

This completes what was previously done for the Java samples, which now also allow AWS downloads.

All this is available in the Developer Community, in the TRTH REST API section.

@Giovanni.Condello, an article on AWS downloads has just been published. You might find it useful to understand this new feature.

Upvotes
3 0 2 8

@veerapath.rungruengrayubkul


I need your advice on clients question

How do I use AWS Direct header in C# SDK, had shared the below


var context = new StandardExtractionsContext(new

Uri("https://hosted.datascopeapi.reuters.com/RestApi/v1/"), "<your user id>", "<your password>");

context.DefaultRequestHeaders.Add("x-direct-download", "true");

var stream = context.UserPackageDeliveryOperations.GetReadStream("<packageDeliveryId>");

You can also use the following code to set the X-Direct-Download header. This will set the header once for a next API call.

Func<System.Collections.Generic.Dictionary<string, string>> directDownload = delegate()
{
    System.Collections.Generic.Dictionary<string, string> header = new System.Collections.Generic.Dictionary<string, string>();
    header.Add("X-Direct-Download", "true");
    return header;
};

ExtractionsContext.SetRequestHeaders(directDownload);

using (var response = ExtractionsContext.RawExtractionResultOperations.GetReadStream(result))


Client wants to now:-

Is this flag help with some persisted query results?

In fact I'm using ExtractionsContext, not StandardExtractionsContext, and there is no such property DefaultRequestHeaders.

And results for each request are not persisted (no extracted files) in your system.

Does it mean, I don't need this DirectDownload option?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea