Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

initializeFileUpload(inputRep)

Used to create an outputRep instance with the below parameters.

Signature

ConnectApi.ContentHubFileUploadConnect.initializeFileUpload(inputRep)

Parameters

  • inputRep:

    Type: Map<String,ANY>

    Enter the input Representation instance created with ConnectApi.ContentHubUploadItemInputRepresentation();

  • Sample Code Snippet:
    1public with sharing class ConnectApiHelper {
    2    @AuraEnabled(cacheable=false)
    3
    4    public static ConnectApi.ContentHubUploadItemRepresentation getS3UploadUrl(String contextId, String fileName, String contentType, Long contentSize) {
    5        try{
    6            ConnectApi.ContentHubUploadItemInputRepresentation inputRep = new ConnectApi.ContentHubUploadItemInputRepresentation();
    7            inputRep.contentSize = contentSize;
    8            inputRep.contentType = contentType;
    9            inputRep.contextId = contextId;
    10            inputRep.fileName = fileName;
    11            final ConnectApi.ContentHubUploadItemRepresentation outputRep = ConnectApi.ContentHubFileUploadConnect.initializeFileUpload(inputRep);
    12            System.debug('File Upload URL:' + outputRep.fileUploadUrl);
    13
    14            return outputRep;
    15        }
    16        catch(Exception ex) {
    17            throw new AuraHandledException('Error in getUploadUrl: ' + ex.getMessage());
    18        }
    19    }
    20}