Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • TRTH /
avatar image
Question by Samadhan · Mar 21, 2019 at 01:13 PM · awsdownload fileaws server

AWS download - X-Direct-Download set to true returns 302 code and doesn't download file.

My Java code:

con = (HttpURLConnection) obj.openConnection();

con.setInstanceFollowRedirects(false);

con.setRequestProperty("X-Direct-Download", "true");

con.setRequestMethod("GET");

con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");

-------------------------------OUTPUT LOG-----------------------------------------------

Downloading File: I:\2018_Work\Out\ATH-2019-03-18-NORMALIZEDMP-Data-1-of-1.csv.gz

Trying to download first time->i=0

realURL :https://s3.amazonaws.com/tickhistory.query.production.hdc-ebd/normalised/ATH/2019-03-18/data/merged/ATH-2019-03-18-NORMALIZEDMP-Data-1-of-1.csv.gz?AWSAccessKeyId=XXXXXXX&Expires=1553209438&response-content-disposition=attachment%3B%20filename%3DATH-2019-03-18-NORMALIZEDMP-Data-1-of-1.csv.gz&x-amz-request-payer=requester&Signature=XXXXX%3D

Output File is Creating Now

responseCode:302

---------------------------------------------

Somehow getting 302 response code but its not downloading the file with streams. Here is my code which downloads file. (Link printed in logs is downloadable though)

DataInputStream readerIS = new DataInputStream(con.getInputStream());

Files.copy (readerIS, Paths.get (fileName), StandardCopyOption.REPLACE_EXISTING);

Please suggest what else is needed here.

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

1 Reply

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by jirapongse.phuriphanvichai · Mar 22, 2019 at 06:04 AM

There are Java examples available in the Downloads section of TRTH - REST API.

The examples demonstrate how to download extraction result from AWS.

You may also refer to this ADVISORY: DIRECTLY DOWNLOADING FROM AMAZON GENERATES ERROR.

In short, the steps are:

1. Configure your HTTP client to not redirect a request when it receives a 302 status code

2. When you receive the Tick History download response with the 302 status code, read the response’s Location header field and send the original download request to that URL. Be sure to omit the Authorization header field and the X-Direct-Download header field


java.jpg (38.0 KiB)
Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
6 People are following this question.

Related Questions

How to Get Data from AWS instead of TRTH server using REST API

AWS URL not getting generated while downloading NFE Ref data

AWS download - X-Direct-Download returns Invalid Argment error : 400 Bad Request

Unable to download the EOD Data via AWS

In odd occasions, the file we get from the stream response is actually an html file -TRTH

  • Feedback
  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Careers
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Calais
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRIT
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • World-Check Data File
  • Explore
  • Tags
  • Questions
  • Badges