How to upload files to an outside service, larger than 3M? And this error on uploading: Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 156.719KB
<apex:page standardController="Employee__c" extensions="EmployeeUploadPhotoController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!saveEmp}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1" showHeader="true">
<apex:sectionHeader title="Employee" subtitle="Upload Photo"/>
<apex:inputFile title="Upload Photo" value="{!body}" fileName="{!name}" accept="png,jpg,bmp,jpeg" id="file"></apex:inputFile>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
controller-
public class EmployeeUploadPhotoController{
public Blob body{get; set;}
public String name{get; set;}
public Attachment objAttach{get;set;}
public Employee__c objEmp{get;set;}
public EmployeeUploadPhotoController(ApexPages.StandardController controller) {
objAttach=new Attachment();
objEmp = (Employee__c)controller.getRecord();
if(objEmp.id!=null)
objEmp = [select id from Employee__c where id=:objEmp.id ];
}
public pagereference saveEmp(){
try {
upsert objEmp;
objAttach.body=body;
objAttach.name=name;
if(objAttach.body!=null && objAttach.name!=null){
objAttach.parentId=objEmp.id;
upsert objAttach;
//objEmp.Image_URL__c='https://c.ap1.content.force.com/servlet/servlet.FileDownload?file='+objAttach.id;
objEmp.Image_URL__c='/servlet/servlet.FileDownload?file='+objAttach.id;
upsert objEmp;
}
objAttach.body=null;
}
catch(Exception e) {
return null;
}
return new pagereference('/'+objEmp.id);
}
}