Skip to content

uploadContentVersion

uploadContentVersion(targetOrgConnection, filePath, title?, firstPublishLocationId?): Promise<ContentVersion>

Defined in: contentVersionUtils.ts:150

Upload a local file as a new ContentVersion.

Only the file’s name is sent to the org as PathOnClient, not the local path it was read from. Salesforce derives FileExtension and FileType from that value, so the name is all it needs — and sending the rest would publish the uploader’s local directory layout into the org, where it is visible to anyone who can query ContentVersion.

Connection

The org connection to upload to.

string

The local filesystem path of the file to upload. Stays local.

string

The ContentVersion title. Defaults to the file’s name.

string

The ID of the record/library to attach the resulting ContentDocument to, if any.

Promise<ContentVersion>

The created ContentVersion, re-queried to include ContentDocumentId.

If the org returns a non-2xx response.