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 a fixed expiration duration of 1 hour.
Create Single Folder
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
sfy_office365.CreateFoldersGlobalMethod.createFolders(new List<sfy_office365.AddFolderGlobalMethod.FolderRequest>(), EMAIL_ADDRESS);
Create Folder Structure
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
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
sfy_office365.UploadFilesGlobalMethod.uploadFiles(new List<sfy_office365.AddFileGlobalMethod.FileRequest>(), EMAIL_ADDRESS);
Get File Links
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);