Google Cloud Storage client object

GCSClient() // object constructor

This function creates and returns a new GCSClient object, which is the AFT object that implements and carries out all file transfers and related operations using the Google Cloud Storage protocol.

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

Bucket:                 string
CredentialsFile:        string //optional, read below...
UseMetadataWhenListing: bool

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

CredentialsFile: unlike other cloud vendors, Google Cloud exports OAuth2 credentials as a JSON file (read this: https://cloud.google.com/docs/authentication/getting-started). Once you have this JSON file, you have 2 options:

  1. either you specify its full path in this CredentialsFile property of the GCSClient object, or

  2. you export its path as an environment variable named GOOGLE_APPLICATION_CREDENTIALS (if you choose this option #2 you don’t need to specify the file’s path in your script, in fact Syncplify.me AFT! will detect it automatically from your environment variables

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 Azure 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 (with explicit location of the credentials file):

{
  var cli = new GCSClient();
  cli.Bucket = 'yourbucketname';
  cli.CredentialsFile = 'C:\\MySecretFolder\\GoogleCloudCreds.json';
  if (cli.Connect()) {
    // perform your file transfers...
    // ...
    // ...
    cli.Close();
  }
  cli = null
}

Example (assuming the GOOGLE_APPLICATION_CREDENTIALS environment valiable exists):

{
  var cli = new GCSClient();
  cli.Bucket = 'yourbucketname';
  if (cli.Connect()) {
    // perform your file transfers...
    // ...
    // ...
    cli.Close();
  }
  cli = null
}