AWS S3 client object

S3Client() // object constructor

This function creates and returns a new S3Client object, which is the AFT object that implements and carries out all file transfers and related operations using Amazon's S3 protocol.

Here’s the protocol-specific properties that you may have to initialize/configure before calling the .Connect() method:

Region:                 string
Bucket:                 string
APIKeyID:               string
APIKeySecret:           string
APIKeySecretFromSecret: string
UseMetadataWhenListing: boolean

Region: this is the AWS region, as specified in AWS’ own documentation. For example us-east-1.

Bucket: this is the name of the S3 bucket that you have chosen and assigned to your bucket when you have originally created it.

APIKeyID: this is the APIKeyID that you have generated in your AWS account to access this bucket.

APIKeySecret: every APIKeyID has a corresponding secret in your AWS account. This is such secret. We do not recommend, though, that you write your secrets in clear in your script code, so either use the GetSecret function to populate this value, or use the APIKeySecretFromSecret property here below (better choice).

APIKeySecretFromSecret: if you have stored your APIKeySecret as aSyncplify.me AFT! secret (read more about secrets) then you can set this property to the name of the secret in Syncplify.me AFT!’s database; this is the safest choice.

UseMetadataWhenListing: this property is by default set to false to optimize the speed of your directory listing and file searching commands. Setting this property to true will slow down directory lists and file searches by a remarkable factor, but it will - in turn - enable the acquisition of the object’s metadata, which include the correct TimeStamp of the last modification date of the object. Unfortunately S3 doesn’t return such information in the normal directory list, so this option necessarily needs to be set to true if your script is using the AdjustTimeOnUpload or AdjustTimeOnDownload options. This is the only way to make sure that the returned TimeStamp matches the custom TimeStamp you set, and not the timestamp that AWS arbitrarily assigns to the object.

Please, keep in mind that once created you (the programmer) have the responsibility of freeing the memory allocated by the object at the end of its use. You can easily do so by simply setting the object to null once you’re done using it (as shown in the example below).

Example:

{
  var cli = new S3Client();
  cli.Region = 'us-east-1';
  cli.Bucket = 'yourbucketname';
  cli.APIKeyID = 'wvb8ye5485ye4y7585';
  cli.APIKeySecretFromSecret = 'your_aws_s3_secret_name';
  if (cli.Connect()) {
    // perform your file transfers...
    // ...
    // ...
    cli.Close();
  }
  cli = null
}