You need to sign in to do that
Don't have an account?
sonam
Push a file to a server
Hi,
I need to merge two codes.
The following code saves the document is salesforce folder.
The same doc needs to be pushed to a server by the method addFile().
/*** Controller ***/
public class documentExt { public documentExt(ApexPages.StandardController controller) { Document d = (Document) controller.getRecord(); d.folderid = UserInfo.getUserId(); //this puts it in My Personal Documents } }
public pagereference addFile() { String fSchema = Label.fileScheme; try{ Blob body=EncodingUtil.Base64Decode(data); // calling method to push file to share folder String path = fileService.fileUploader(fileName,body,fSchema); //system.debug('File Path-----'+path); File__c f=new File__c(); f.Full_File_Name__c=fileName; f.File_Path__c=path; List<String> filenames=fileName.replace('.','#').split('#'); f.name=(filenames[0].length()>80)?(filenames[0].subString(0,79)):filenames[0]; f.Type__c=filenames[1]; String objectName=UtilityClass.findObjectNameById(parentId); insert f; data=''; fileName=''; parentId=''; contentType=''; msg='normal'; return null; } catch(Exception ex) { msg=ex.getMessage(); data=''; fileName=''; return null; } }