Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

uploadAttachment(file, onUploadProgress, errorHandler, context)

Updated on July 20, 2021

Uploads a file to the server.

Returns

A Promise that uploads a file to the server.

Parameters

NameTypeDescriptionRequired
fileobjectThe file that needs to be uploaded to the server.
onUploadProgressfunctionA callback function that obtains the upload progress of the file.
errorHandlerfunctionA callback function to handle exceptions.
contextstringThe name of the context where the API is being called.

Usage example

In this example, the API uploads a file to the server.

const onUploadProgress = (ev) => {
 // ev is a progress type event
 // which has total, loaded properties to calculate progress
}

const errorHandler = (error) => {
 // handle error here
}

PCore.getAttachmentUtils().uploadAttachment(file, onUploadProgress, errorHandler , 'app/primary_1')
.then((fileResponse) => {
  const fileId = fileResponse.data.ID;
}).catch(err => {
   // Error handling
});
  • Previous topic linkAttachmentsToCase(caseID, attachments, attachmentType, context)
  • Next topic APIs in the AuthUtils module

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us