# Copy Salesforce Files

Copy Salesforce Files to external storage from Apex. Files are queued and processed at a dynamic rate based on the external library, with no file-size limit.

> Kind: Apex method · Updated: 2026-07-01

## Signature

```apex
global static void upload(
  List<Types.UploadSalesforceFilePayload> files,
  String runAs
)
```

### Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| files | List&lt;<a href="#/apex-type-upload-salesforce-file-payload">Types.UploadSalesforceFilePayload</a>&gt; | required | List of Types.UploadSalesforceFilePayload objects, one per Salesforce file to copy. |
| runAs | String | required | Email Id of the user on whose behalf the function should run. To run the action as the automation user, supply integrationUser. |

## Return Type

void — after a file is successfully copied, a Salesforce File Copied platform event is published. You can use this event as a trigger in Apex or flows to delete the Salesforce file using the delete SObject method.

## Example

```apex
List<cldfs.Types.UploadSalesforceFilePayload> inputs = new List<cldfs.Types.UploadSalesforceFilePayload>{
  new cldfs.Types.UploadSalesforceFilePayload(
    '069DO000000hwB8YAI',
    'sharepoint',
    '01PLJOYLOAWJBFGBSE7FHK5AKOSIMDIO6H',
    'b!ZfA15HRS1Uy9pH3Vw5tFjAHfP1lRYlZAvDwLnHYYq8sa-L6ejXB-TJbMYUxi1QfL',
    null
  )
};

cldfs.Client.upload(inputs,'integrationUser');
```
