-1

I need to upload file to AWS S3 service, in UniBasic/UniData. The requirement is to call Amazon S3 HTTP REST API directly in UniBasic, using AWS Signature Version 4. Any examples out there?

E_net4
  • 27,810
  • 13
  • 101
  • 139
Marvado
  • 1
  • 3

1 Answers1

0

Approach this and all such challenges in two parts. First, be 100% positive that you know how to craft and send the proper REST API query from an OS command line. Be sure that you know how to process the response that comes back. Second, work out how to do the exact same operation from BASIC ... or whatever your toolkit is.

So let's say you have a URI like http://foo.bar.s3.tld/api?auth=xxx&operation=... Get that to work from DOS or Linux.

With that working 100% to upload your file to Amazon S3, the next challenge is to do the same from BASIC in Unidata.

* Build the command (I know nothing about the S3 API, use correct params)
SITE = "http://....?"
QUERY = "auth=":AUTHKEY:"&operation=..."
QUERY := "&filename=/os/path/" : FILENAME.PASSED.IN
URI = SITE : QUERY

All the pieces are in place. Now to execute you have a few options:

EXECUTE "SH -C ":URI CAPTURING OUTPUT

The OUTPUT may have JSON that needs to be parsed for a GUID or other info.

Another approach: Check the UniData UniBasicExtensions Reference Guide Chapter 2 - Using CallHTTP.

You can also put the command into the OS in a script with any language with which you're comfortable. You didn't tell us your OS so I'll assume Linux here. Use BASH or PHP or any other language to accept command-line arguments and set them into a query. Execute the query and echo the result. Now in BASIC :

SCRIPT = "./path/to/scriptname"
COMMAND = SCRIPT : " " : AUTHKEY : " " : FILENAME.PASSED.IN
EXECUTE "SH - C ":COMMAND CAPTURING OUTPUT

You can parse the output in BASIC, or capture the output in your OS script, parse it there with common tools, extract the data you need, and echo only the data in an easy to parse format in BASIC.

So, verify your command and response and choose a solution from the above. If it doesn't work let's take another shot. If it does work, it will help the next person if you post your code without AUTH codes (that should be set in variables).

If we don't solve this here:

  1. Ask your Value-Add Reseller (VAR) ... you're already paying them for support, use it.
  2. Email Rocket Support, point them to this thread, tell them what you've done, and you will almost certainly get a solid response.
  3. Try the Rocket community/forum.

Good luck!

TonyG
  • 1,432
  • 12
  • 31