Already Gone through many different links related to this Error, but still in problem. Getting this error when I am uploading large size file. If I am using the Transient keyword then my i am unable to update my Document, Please suggest me what to do!!!
Vf page
<apex:page docType="HTML-5.0" controller="AdminPannelController" id="pgId">
<apex:form id="frmId" >
<apex:pageBlock title="Live Agent Configure " id="pgBlockId">
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockSection id="pbsection" columns="2">
<apex:outputLabel value="LOGO: ">
<apex:outputText value="{!callfunc}" escape="false"/>
<apex:inputFile value="{!file.body}" fileName="{!file.Name}" fileSize="{!file.BodyLength}"></apex:inputFile>
</apex:outputLabel>
<apex:pageBlockButtons location="Bottom" id="pbButton">
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Reset" action="{!reset}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
My controller
public with sharing class AdminPannelController{
transient public Document file{get;set;}
public String textUrl{get;set;}
transient public List<brand__mdt> BrandTypes = new List<brand__mdt>();
public AdminPannelController(){
file = new Document();
flag = false;
}
public void save(){
List<brand__mdt> productNameFromMetaData = [Select DeveloperName from brand__mdt where id =: metaData limit 1];
List<Folder> existingFolder = [Select Id,Name from Folder where Name = 'Product Logo Folder' limit 1];
List<Folder> existingTextFolder = [Select Id,Name from Folder where Name = 'Product Text Folder' limit 1];
Document Doc = new Document();
try{
List<AdminPanelBranding__c> existingColorCode = [Select Background_Color__c from AdminPanelBranding__c where Name =: productNameFromMetaData[0].DeveloperName ];
if(colorCode == ''){
system.debug('in if loop of colorCode');
if(existingColorCode.size() > 0){
colorCode = existingColorCode[0].Background_Color__c;
}
}
List<Document> existingDoc = [Select Name,Id,Body from Document where Description =: metadata AND FolderId =: existingFolder[0].id limit 1];
System.debug('existing doc' +existingDoc);
System.debug(file);
if(file.Name == null){
System.debug('in null loop should insert');
if(existingDoc.size() > 0){
Doc.id = existingDoc[0].id;
Doc.name=file.Name;
Doc.Body=file.Body;
Doc.Description = metadata;
Doc.Folderid = existingFolder[0].id;
System.debug(file.BodyLength);
update Doc;
}
}
else{
if(existingDoc.size() > 0){
System.debug('file'+file);
system.debug('size loop');
Doc.id = existingDoc[0].id;
Doc.name=file.Name;
Doc.Body=file.Body;
Doc.Description = metadata;
Doc.Folderid = existingFolder[0].id;
System.debug(file.BodyLength);
if(file.BodyLength <= 135000 ){
System.debug('in loop of body');
update Doc;
flag = false;
}
else{
flag = true;
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Text Document , Please upload a Text/Plain Document with less than 135kb size');
}
}
else{
System.debug('not null and insert file');
Doc.name=file.Name;
Doc.Body=file.Body;
Doc.Description = metadata;
Doc.Folderid = existingFolder[0].id;
if(file.BodyLength <= 135000 ){
system.debug('inside body length');
insert Doc;
flag = false;
}
else{
flag = true;
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Text Document , Please upload a Text/Plain Document with less than 135kb size');
ApexPages.addMessage(myMsg);
}
}
}
}Catch(Exception e){
e.getMessage();
}
}