You need to sign in to do that
Don't have an account?
ShreyasMangalvedhekar
ContentVersion
I Have written code to create the ContentVersion, its getting created successfully but without extension,
I need to place extension, any suggestion on same ? folowing is my code :
I need to place extension, any suggestion on same ? folowing is my code :
@AuraEnabled public static boolean saveTheFile(String base64Data, String contentType, string filename) { base64Data = EncodingUtil.urlDecode(base64Data, 'UTF-8'); /*Start : File Attachment as Files Object*/ ContentVersion conVer = new ContentVersion(); //Create the COntentVersion conVer.ContentLocation = 'S'; // S specify this document is in SF, use E for external files conVer.PathOnClient = 'Proposal'; // The files name, extension is very important here which will help the file in preview. conVer.Title = fileName; // Display name of the files conVer.pathOnClient = '/file'; conVer.VersionData = EncodingUtil.base64Decode(base64Data); // converting your base64 string to Blog insert conVer; //Create ContentDocumentLink ContentDocumentLink cDe = new ContentDocumentLink(); cDe.ContentDocumentId = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:conVer.Id].ContentDocumentId;//Link the contentDOcumentID cDe.LinkedEntityId = predictID; cDe.ShareType = 'I'; // Inferred permission, checkout description of ContentDocumentLink object for more details cDe.Visibility = 'AllUsers'; insert cDe; //Update the Filename at the end once the Content Documents are created. return true; }
as file is getting uploaded in system without extension , the preview is not available ?