S-Drive 3.6 Documentation

getBucketNameWithFileId

Returns the name of the storage bucket an existing file is stored in, given just the file's own Id. A friendlier variant of getBucketName's (objectId, fileObjectName) overload — this one detects the file object type for you from the Id itself, and falls back to your org's default bucket instead of raising an error if nothing more specific is found.

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 getBucketNameWithFileId(String fileId)

Parameters

Parameter

Type

Required

Description

fileId

String

Yes

Id of an existing file record.

Return value

Returns a String — the bucket name that file is stored in. Falls back to your org's default bucket if no more specific bucket assignment is found for that file.

Example

String bucketName = cg.SDriveTools.getBucketNameWithFileId(existingFile.Id);