I am trying to upload a document that is less than 1MB in size but it has 5000+ records with 6 columns of fields, I am getting below error
Regex too complicatedError is in expression '{!ReadFile}' in component <apex:commandButton> in page importcsvfilepage: Class.ImportCSVFile.ReadFile: line 11, column 1
when I try to upload with 130KB file of 800 records not getting any error. As we have 6MB is the max size we can upload why am I getting this error?
when I upload a file records will create.
VF Page:
<apex:page sidebar="false" controller="ImportCSVFile">
<apex:form >
<apex:sectionHeader title="Upload CSV data File"/>
<apex:pageBlock >
<center>
<apex:inputFile value="{!FileContent}" filename="{!Filename}" /> <apex:commandButton action="{!ReadFile}" value="Upload File" id="theButton" style="width:70px;"/>
<br/> <br/> <font color="red"> <b>Note: Please use the standard template to upload Accounts.</b> </font>
</center>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex class:
public class ImportCSVFile
{
public string Filename{get;set;}
public Blob FileContent{get;set;}
String[] filelines = new String[]{};
List<Account> accstoupload= new List<Account>();
public Pagereference ReadFile()
{
Filename=FileContent.toString();
filelines = Filename.split('\n');
for (Integer i=1;i<filelines.size();i++)
{
String[] inputvalues = new String[]{};
inputvalues = filelines[i].split(',');
Account a = new Account();
a.Name = inputvalues[0];
a.ShippingStreet = inputvalues[1];
a.ShippingCity = inputvalues[2];
a.ShippingState = inputvalues[3];
a.ShippingPostalCode = inputvalues[4];
a.ShippingCountry = inputvalues[5];
accstoupload.add(a);
}
try{
insert accstoupload;
}
catch (Exception e)
{
ApexPages.Message errormsg = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured. Please check the template or try again later');
ApexPages.addMessage(errormsg);
}
return null;
}
public List<Account> getuploadedAccounts()
{
if (accstoupload!= NULL)
if (accstoupload.size() > 0)
return accstoupload;
else
return null;
else
return null;
}
}
What is the max size file or No of records in a File I can upload without any error?
I need to understand the main reason for these errors when we upload data.