Skip to main content
Skip table of contents

Use 24Files with Apex

Parameters

The following capitalized items need to be replaced by your specific values when calling the 24Files Apex methods:

  • RECORD_ID = ID of the record

  • FOLDER = relative folder to the record folder. Note: in case of anonymous access, you can only upload in the public folder. Hence, leave the FOLDER argument empty ''.

  • USE_ANONYMOUS_AUTH = set to ‘true’ to use anonymous auth or ‘false’ to use authenticated auth

  • EMAIL_ADDRESS = email address where results should be sent to

  • CONTENT_VERSION_ID = Salesforce content version id where the file is stored in

  • PATH = relative path to the file from the record folder

Limitations

  • With APEX, file uploads are limited to a maximum size of 35 MB per file.

  • The getFileLink APEX method returns a link with an expiration duration that has been set in the 24Files Settings page in the 24Files Manager app.

Create Single Folder

CODE
sfy_office365.AddFolderGlobalMethod.FolderRequest folderRequest = new sfy_office365.AddFolderGlobalMethod.FolderRequest(RECORD_ID, FOLDER, USE_ANONYMOUS_AUTH);
sfy_office365.CreateFoldersGlobalMethod.createFolder(folderRequest, EMAIL_ADDRESS);

Create Multiple Folders

CODE
sfy_office365.CreateFoldersGlobalMethod.createFolders(new List<sfy_office365.AddFolderGlobalMethod.FolderRequest>(), EMAIL_ADDRESS);

Create Folder Structure

CODE
List<sfy_office365.GenerateFolderStructureGlobalMethod.FolderStructureRequest> generateFolderStructures = new List<sfy_office365.GenerateFolderStructureGlobalMethod.FolderStructureRequest>{new sfy_office365.GenerateFolderStructureGlobalMethod.FolderStructureRequest(RECORD_ID, USE_ANONYMOUS_AUTH, EMAIL_ADDRESS)};
sfy_office365.GenerateFolderStructureGlobalMethod.generateFolderStructure(generateFolderStructures);

Upload File

CODE
sfy_office365.AddFileGlobalMethod.FileRequest uploadFile = new sfy_office365.AddFileGlobalMethod.FileRequest(RECORD_ID, FOLDER, CONTENT_VERSION_ID, USE_ANONYMOUS_AUTH);
sfy_office365.UploadFilesGlobalMethod.uploadFile(uploadFile, EMAIL_ADDRESS);

Upload Files

CODE
sfy_office365.UploadFilesGlobalMethod.uploadFiles(new List<sfy_office365.AddFileGlobalMethod.FileRequest>(), EMAIL_ADDRESS);
CODE
List<sfy_office365.GetFileLinksGlobalMethod.FileLinkRequest> fileLinkRequests = new List<sfy_office365.GetFileLinksGlobalMethod.FileLinkRequest>{new sfy_office365.GetFileLinksGlobalMethod.FileLinkRequest(RECORD_ID, PATH, USE_ANONYMOUS_AUTH)};
sfy_office365.GetFileLinksGlobalMethod.getFileLink(fileLinkRequests);

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.