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-apic#rest-api
icon clock
10 |1500

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

Hi @Giovanni.Condello

I hope you are going well. Say "Hi" to the TechGap team for me.

Thank you for your participation in the forum.

Does the reply below answer your question?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide other community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

Olivier for AHS

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 512.0 KiB each and 1.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
5 2 9 12

@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 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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