Google Cloud Storage

Create a bucket on Cloud Storage

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to create a bucket in GCS in a specific location and storage class. The location identifies the geographical position of the bucket around the world. For more information see:

The storage class defines how fast will be the file retrieval. For more information see:

Be aware that the bucket name must be unique at Google level and must contain only letters and - (no underscore symbols), so it would be a good practice to use composed names starting with the googleprojectname-applicationame-somethingelse.

Syntax

var descriptor = utils.createGoogleCloudStorageBucket(
   project, 
   bucketName, 
   bucketLocation,
   storageClass
);

Description

Get the bucket descriptor from Cloud Storage

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to get the description of an already existing bucket in GCS.

Syntax

var descriptor = utils.getGoogleCloudStorageBucket(bucketName);

Description

Get the file descriptor from Cloud Storage

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to get the description of an already existing file stored inside a Google Cloud Storage bucket.

Syntax

var descriptor = utils.getGoogleCloudStorageObject(bucketName,objectName);

Description

Get a public (temporary) URL for accessing a Cloud Storage file

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to generate a public URL to access from anywhere an already existing file stored inside a Google Cloud Storage bucket.

Syntax

var urlString = utils.getGoogleCloudStorageSignedURL(
   verb, 
   expiration, 
   bucketName, 
   objectName, 
   mime
);

Description

Download on the Platform server file system a file stored in Google Cloud Storage

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to download an already existing file stored inside a Google Cloud Storage bucket and save it locally, on Platform server file system.

Syntax

utils.downloadGoogleCloudStorageObject(
   bucketName, 
   objectName, 
   destPath
);

Description

It fires and exception in case of errors.

Get a paginated list of files stored in the specified bucket of Cloud Storage

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to get a paginated list of files stored inside a Google Cloud Storage bucket. The list does NOT contain the files, but only file descriptors (helpful to fetch a specific file later).

Syntax

var response = utils.listGoogleCloudStorageObjects(
     bucketName, 
     maxPageResults, 
     pages, 
     nextPageToken, 
     prefix, 
     delimiter
  )

Description

Get the whole list of files stored in the specified bucket of Cloud Storage

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to get a the whole list of files stored inside a Google Cloud Storage bucket. The list does NOT contain the files, but only file descriptors (helpful to fetch a specific file later).

Syntax

var list = utils.listGoogleCloudStorageObjects(
     bucketName, 
     prefix, 
     delimiter
  )

Description

Upload a file saved on Platform server file system to the specified bucket of Cloud Storage

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to upload an already existing file stored on Platform server file system and save it on a Google Cloud Storage bucket.

Syntax

var descriptor = utils.uploadGoogleCloudStorageObjectFromFS(
   fsPath, 
   bucketName, 
   objectName,
   deleteFsFile
);

Description

Important note: the file visibility is inherited by the bucket: if the bucket has been defined as "£public" the uploaded file will be as well.

Upload a file saved on Platform server file system to the specified bucket of Cloud Storage and make it public

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to upload an already existing file stored on Platform server file system and save it on a Google Cloud Storage bucket and make it public, i.e. accessible by any device, without any authentication.

Syntax

var descriptor = utils.uploadGoogleCloudStoragePublicObjectFromFS(
   fsPath, 
   bucketName, 
   objectName,
   deleteFsFile
);

Description

Important note: the file visibility is always public, independently on the bucket settings.

Create a text file on a specified bucket of Cloud Storage

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to create on the fly a text file and upload it on a Google Cloud Storage bucket, without the need for a physical file stored on Platform server file system.

Important note: do NOT use this method to create on the fly very large text files, since this would consume a large amount of memory on Platform server; use it only for kbytes size files.

Syntax

var descriptor = utils.uploadGoogleCloudStorageObjectFromString(
  textContent, 
  bucketName, 
  objectName,
  contentType
);

Description

Important note: the file visibility is inherited by the bucket: if the bucket has been defined as "£public" the uploaded file will be as well.

Create a text file on a specified bucket of Cloud Storage and make it public

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to create on the fly a text file and upload it on a Google Cloud Storage bucket, without the need for a physical file stored on Platform server file system and make it public, i.e. accessible by any device, without any authentication.

Important note: do NOT use this method to create on the fly very large text files, since this would consume a large amount of memory on Platform server; use it only for kbytes size files.

Syntax

var descriptor = utils.uploadGoogleCloudStoragePublicObjectFromString(
  textContent, 
  bucketName, 
  objectName,
  contentType
);

Description

Important note: the file visibility is always public, independently on the bucket settings.

Duplicate a file stored in the specified bucket of Cloud Storage

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to duplicate an already existing file stored on a a Google Cloud Storage bucket and save it on the specified bucket with the specified file name; a possibile use of this method is when creating a file from a template file.

Syntax

var descriptor = utils.copyGoogleCloudStorageObject(
  sourceBucketName, 
  sourceObjectName,
  sourceObjectVersion, 
  destinationBucketName, 
  destinationObjectName
);

Description

Change accessibility for a Cloud Storage file to public or private

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to change the access policy for an already existing file stored on a a Google Cloud Storage bucket and make it public or private.

Syntax

utils.setPublicLink(bucketName, objectName, publicLink)

Description

This method will fire and exception in case of errors.

Delete a Google Cloud Storage file

Before using this function, the GCP project must be set up correctly, i.e. you have to specify at global parameters level:

  • GOOGLE

    • Google: Service Account Email

    • Google: Service Account Key

  • FILE UPLOAD

    • Google Cloud Storage Location (US, EU, ASIA)

    • Google Project Id

Once done that, you can start using the Google Cloud Storage (GCS) service.

The current javascript function allows to delete a file from a bucket.

Syntax

utils.deleteGoogleCloudStorageObject(String bucketName, String objectName)

Description

This method will fire and exception in case of errors.

Last updated