Sample Ruby script

The attached ruby script named opswatFileDownloadClient.rb provides the above functionality. You can use it to download the required file and also to upload a public key.

The available options are as follows:

  • ‘--gateway <URL>’ will direct communication to the gateway on the specified URL.

  • ‘--token <download token>’ can be used to supply your download token

  • ‘--upload-public-key’ will let you post a new RSA public key. You will need to provide the path to the public key using ‘--keyfile’

  • ‘--keyfile <path to file>’ is used to tell the script where your private/public key is present. Note that for file download, the path to your private key is required NOT the public key. The public key has to be supplied only when using ‘--upload-public-key’. If no public key is associated with the account, do not use this option.

  • ‘--protocol <http/https>’ tells the script if it should use HTTPS or not. The default is HTTP is this option is not used.

  • ‘--port <port number>’ can be used if the gateway is listening on a specific port other than default internet port.

Typical command to download a file:

ruby opswatFileDownloadClient.rb --token OPSWAT_DOWNLOAD_TK_00000000000000000 --protocol http --keyfile keys/mykey.pem --gateway localhost

Typical command to download a file using default server, port, protocol, no keyfile, and download token of OPSWAT_DOWNLOAD_TK_6d5342970c1945a8a8c736f516947059d, specifying a file of vmod-om.dat:

ruby opswatFileDownloadClient.rb --token OPSWAT_DOWNLOAD_TK_6d5342970c1945a8a8c736f516947059d --file vmod-om.dat

Typical command to upload a new public key:

ruby opswatFileDownloadClient.rb --token OPSWAT_DOWNLOAD_TK_00000000000000000 --protocol https --gateway watch.opswat.com --upload-public-key --keyfile keys/pubkey.pem