This tutorial explains how to automate the download of a faspex package and its content from a faspex package download link.  These links are normally in the format of: 

Example: Package recipient has Faspex account

https://FASPEX_SERVER/aspera/faspex/received/DELIVERY_ID/** Example **/https://acme-faspex.com/aspera/faspex/received/4044

Example: Package recipient uses external email

https://FASPEX_SERVER/aspera/faspex/external_deliveries/DELIVERY_ID?passcode=PASSCODE/** Example **/https://acme-faspex/aspera/faspex/external_deliveries/4822?passcode=7e1b56a2206506bcb1d47beb33598b12d2a8507a

A faspex package download is actually a regular FASP transfer using a FASP URL, you might need to build a transfer spec JSON, a XferParams or extract an ascp command from the URL.  Therefore, the first step is to get the FASP URL that corresponds to the faspex package.  To do this you need to send a HTTP GET request to the faspex server using the download URL with an accept header set to application/xml.  After that you will need to generate an authorization token for downloading the package (this token can be generated by a faspex user account).  Finally you will need to start the download using the transfer parameters and the authorization token.


1. Get the FASP URL

Depending on whether or not your recipient has an account with the faspex server will dictate the command you will use.  For example if your recipient has an account you would use /receiveid/{id} and if your recipient does not have an account you will use /external_deliveries/{deliveriy_id}?passcode={passcode}.  For example:

##With Account:curl -ki --basic -uMYACCOUNT:MYPASSWORD -H "Accept: application/xml" -X GET https://acme-faspex.com/aspera/faspex/received/4044##Without Account:curl -ki -H "Accept: application/xml" https://acme-faspex/aspera/faspex/external_deliveries/4822?passcode=7e1b56a2206506bcb1d47beb33598b12d2a8507a

This command would yield the response seen below. This response contains the FASP URL for downloading the entire package in the link tag as well as the FASP URL for each of the contents of the faspex package. You can use any XML parser to extract the FASP URLs.

 

2. Generate Authorization Token

A faspex transfer needs to be authorized by the server with a valid authorization token.  The authorization call to the faspex API /aspera/faspex/issue-token?direction=down will generate the needed token.  If the request is successful a download token will be returned, for recipients without faspex accounts an authorization token will need to be requested from the faspex sender or administrator.  For example, you could run the following cURL command using the payload.xml file seen below.

curl -ki --basic -uMYACCOUNT:MYPASSWORD -H "Content-Type: application/vnd.aspera.url-list+xml" -H "Accept: text/plain" -d @payload.xml https://acme-faspex.com/aspera/faspex/issue-token?direction=down

payload.xml

 

3. Start the Download

The FASP URL and the authorization token are now ready to be used to start the download.  Depending on the API/SDK used to download hte content, the FASP URL may be converted into:

  • transferSpec JSON Object, to be used with the Connect JavaScript API
  • XferParams, to be used with the FASPManager SDK
  • Command Line, to be used with ascp

The FASP URL can be processed to create any of the items above.  For more information on how to process the FASP URL please see the FASP URL Syntax page.  For example, if you had the following FASP URL and token:

FASP URL

<link rel="package" href="fasp://faspex@acme-faspex.com:33001/test - 002de384-85ba-4a3c-9239-aae57f657814.aspera-package/PKG - test?cookie=aspera.faspex20:d:176cc5df-2df8-4c09-ae93-2b39f3e0ed7b:dG9ibw:eyJfcGtnX3V1aWQiOiIwMDJkZTM4NC04NWJhLTRhM2MtOTIzOS1hYWU1N2Y2NTc4MTQiLCJfcGtnX25hbWUiOiJ0ZXN0IiwiX2NyZWF0ZWRfdXRjIjoiMjAxNC8wNS8yNiAxMzo0ODozNyArMDAwMCJ9:dGVzdA&port=33001&policy=fair&targetrate=45000&minrate=0&enc=aes128&fallback=yes&httpport=443&auth=no&createpath=no&lockpolicy=yes&lockminrate=yes&bwcap=100000&v=2"/>

Token

ATM2_ACsII-7P2023EThXT4xzcN9Ozs1h2XnpyiEXQpYr2I7W0QAAI3nLg_88FDWsLIFRzIbcGJ_2MTA

With this FASP URL and token you could generate the following transferSpec JSON, XferParams, or ascp command.

transferSpec JSON

 

XferParams (Java)

 

ascp Command

export ASPERA_SCP_TOKEN=ATM2_ACsII-7P2023EThXT4xzcN9Ozs1h2XnpyiEXQpYr2I7W0QAAI3nLg_88FDWsLIFRzIbcGJ_2MTAexport ASPERA_SCP_COOKIE=aspera.faspex20:d:176cc5df-2df8-4c09-ae93-2b39f3e0ed7b:dG9ibw:eyJfcGtnX3V1aWQiOiIwMDJkZTM4NC04NWJhLTRhM2MtOTIzOS1hYWU1N2Y2NTc4MTQiLCJfcGtnX25hbWUiOiJ0ZXN0IiwiX2NyZWF0ZWRfdXRjIjoiMjAxNC8wNS8yNiAxMzo0ODozNyArMDAwMCJ9:dGVzdAascp - O 33001 -P 33001 -l 45000 -m 0 -i privateKeyPath --mode=recv --user=faspex --host=“acme-faspex.com” --policy=fair "/test - 002de384-85ba-4a3c-9239-aae57f657814.aspera-package/PKG - test" /home/Downloads/
Video player

Video

×