S-Drive 3.6 Documentation

Deleting Files

We think of an S-Drive file as a file stored in the bucket along with the record in Salesforce that allows you to see and interact with the file in the bucket.

SDriveTools has two methods for deletion methods. The first, deleteFiles, deletes the “entire” file, deleting both the Salesforce record and the actual file from the bucket. The second, deleteS3Files, deletes only the file from the bucket.

deleteFiles vs deleteS3Files

Method

Deletes the Salesforce record

Deletes the stored bytes (S3/GCS)

Use it when

deleteFiles

Yes

Yes, by default (can be turned off)

You want a file's Salesforce record and its stored bytes removed together, in one call. This is what most integrations should use.

deleteS3Files

No — never touches Salesforce records

Yes

You need to delete stored bytes without touching the Salesforce record — e.g. you're deleting the record separately (perhaps in bulk, or on a different schedule), or you're cleaning up a storage object that has no matching Salesforce record at all.

If you call deleteS3Files and don't separately delete the Salesforce record, that record still exists but points at a file that no longer exists — trying to download it will fail. Plan to delete or update the record yourself if that's not what you want. deleteFiles doesn't have this problem, since it handles both sides in the same call.