S-Drive 3.6 Documentation

getBucketName

getBucketName

Returns the name of the bucket configured for your org. In the case of multi-bucket configuration, it returns the name of the default bucket unless you include a parameter.

This is an optional, supporting piece for anyone making their own direct calls to the storage backend (S3). Most integrations won't need it unless they're bypassing S-Drive's own upload/download flow.

How to call this method

global static String getBucketName()

global static String getBucketName(String objectId, String fileObjectName)

global static String getBucketName(String bucketId)

Three ways to resolve a bucket name, depending on what you already know:

Overload

Use it when...

getBucketName()

You just want your org's default configured bucket.

getBucketName(objectId, fileObjectName)

You already have an existing file record's own Id and its file object type, and want to know which bucket that specific file is stored in.

getBucketName(bucketId)

You already have a specific bucket's Id (from a cg__SDriveBucketList__c record) and just want its name.

Parameters

Parameter

Type

Description

objectId

String

Id of the existing file record itself (not its parent record) — e.g. an Account File record's own Id.

fileObjectName

String

Full API name of the file object, e.g. cg__AccountFile__c.

bucketId

String

Id of a specific cg__SDriveBucketList__c bucket configuration record.

Return value

Returns a String — the bucket name.

If your org hasn't configured Multi-Bucket Settings for that file object type, this returns your org's default bucket without ever looking up the file record.

Example

String bucketName = cg.SDriveTools.getBucketName(existingFile.Id, 'cg__AccountFile__c');