Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

File Download query

Hi All,

I want to hit up the Brains Trust with a query if I may.

We are doing an integration with a 3rd-party logistics company. When a despatch gets delivered it will trigger a webhook on their end. The will send us some JSON that we will intercept with SRP's wonderful HTTP Framework (shameless plug). After parsing and finding the appropriate key values we will then trigger our own call to one of their other API's to get other pertinant information, including the location of some files in a S3 bucket.

Conceptually, we are all good to this stage.

My experience drops the ball in exactly how, within OI/SRP HTTP Framework, I can initiate the download of that file so I can save it to a specified filepath/filename.

Any suggestions welcome :)

Thanks in advance.


  • edited October 30
    I may be oversimplifying it but I'd start with something like this

    fileLocation = "whereverTheS3BucketSaysItIs" downloaded = HTTPClient_Services('SendHTTPRequest', 'GET', fileLocation) StatusCode = HTTPClient_Services('GetResponseStatusCode') ResponseBody = HTTPClient_Services('GetResponseBody') ResponseHeaderFields = HTTPClient_Services('GetResponseHeaderFields')
    ResponseBody would contain the file but you'd likely need to know some more info about it because it would probably be encrypted for example.
    Other than that hurdle, you would just use OSWrite to write the file to your preferred location
  • Mark,

    Thanks for the tip! I didn't realise I could do that although, upon reflection, I can't think of a reason why I thought that. Maybe I just didn't think hard enough.

    I will give it a go.

  • Will - Mark has the right idea but your 3PL should be giving you some good documentation and I would expect that you'll need to provide appropriate Request Headers so you can get the data in the format expected.
  • edited October 30

    The 3PL actually has some very good docs for their API (both Postman and Swagger) but not so much on their S3 bucket. The link they return (via a authenticated request) is self-signed and short expiry (and unencrypted).

    The ResponseHeaderFields proved it was already the jpeg image I wanted (though I will put in a check when implementing).

    Long story short, your solution was spot on @AusMarkB !
Sign In or Register to comment.