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.
Parameters
Section titled “Parameters”targetOrgConnection
Section titled “targetOrgConnection”Connection
The org connection to upload to.
filePath
Section titled “filePath”string
The local filesystem path of the file to upload. Stays local.
title?
Section titled “title?”string
The ContentVersion title. Defaults to the file’s name.
firstPublishLocationId?
Section titled “firstPublishLocationId?”string
The ID of the record/library to attach the resulting
ContentDocument to, if any.
Returns
Section titled “Returns”Promise<ContentVersion>
The created ContentVersion, re-queried to include ContentDocumentId.
Throws
Section titled “Throws”If the org returns a non-2xx response.