a5_url_from_storageJSONFormat Function



C result = a5_url_from_storageJSONFormat(json as C [, numberOfSecondsBeforeURLExpires as N ])



A JSON object with the following properties:


Storage connection string


Name of object


Vendor. Alpha Anywhere currently only supports Amazon S3, so this property must be set to 'S3'.


Default value is 240. Defines the number of seconds before the URL expires.


Generates a signed URL to download a file from Amazon S3 storage.


The a5_url_from_storageJSONFormat function generates a signed URL to download a file from Amazon S3 storage. a5_url_from_storageJSONFormat can be used to display/download a file from storage (e.g. Amazon S3) directly, with very little load on the Alpha Anywhere Application Server. The purpose of the function is to take a JSON string that defines the address of an object in storage (e.g. Amazon S3) and to generate a signed URL that can be used to download the object directly to the client from storage without having to first download the object to the Alpha server and then have the Alpha server send the file to the client.

The a5_url_from_storageJSONFormat function takes a JSON definition, such as "{cs: 'alphamediacapture',object: 'my_movies7.xlsx',source: 'S3'}", for an object in storage on a site like Amazon S3. It then uses this JSON to generate a signed URL so that the object can be downloaded and displayed on the client from storage.

The 'numberOfSecondsBeforeURLExpires' flag, an optional second parameter, defines how long the URL is valid. If the stored object is protected, this flag specifies the number of seconds that the URL can be used after it has been generated. The default timeout is 240 seconds. If the URL is used more than 240 seconds after being generated, Amazon S3 will return a 'permission denied' error.

The JSON string format that defines the address of an object in storage is:

{cs: 'storage connection string', object: 'name of object', source: 'vendor'}
Currently the only vendor supported is Amazon S3 so vendor must be set to 'S3'
The storage connection string is defined by selecting the Tools, Storage Connection Strings menu when the Web Projects Control Panel has focus. When you define storage connection strings you have the option of encrypting the storage connection string. Do NOT encrypt the storage connection string or else Alpha Anywhere will not be able to parse the storage connection string to determine your storage credentials.

For example, assume you have a named storage connection string called 'myS3bucket'. A JSON string that defines the address of an object called 'ProductPrices.pdf' would be:

{cs: 'myS3bucket', object: 'ProductPrices.pdf', source: 'S3'}

To generate a URL to display or download this object you would do the following:

dim address as c address =
cs: 'myS3bucket', 
object: 'ProductPrices.pdf', 
source: 'S3' 
dim url as c 
url=a 5_url_from_storateJSONformat(address)

The resulting URL would look something like this (assuming that the bucket name specified in the connection string was 'myBucket'):

AWSAccessKeyId=key Expires=expiration&Signature=signature


  • key

    your access key - as defined in the storage connection string

  • expires

    indicates how long the URL can be used for (only applies if the object was uploaded to storage as 'Protected Read')

  • signature

    A special signature based on the credentials specified in the storage connection string.

See Also