function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ShreyasMangalvedhekarShreyasMangalvedhekar 

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 : 
@AuraEnabled
    public static boolean saveTheFile(String base64Data, String contentType, string filename) { 
User-added image
        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;
      
    }

 
ShreyasMangalvedhekarShreyasMangalvedhekar
User-added image
as file is getting uploaded in system without extension , the preview is not available ?