I am using React js, Mobx as storage management and API control with .NET core
User has to select *.csv file and process that file, each row to be inserted in the SQL Server. I am struggling to get CSV data from UI to API
I tried in React Js
const loadData = (event: any) => {
if (window.File && window.FileReader && window.FileList && window.Blob) {
var file = event.target.files[0];
var reader = new FileReader();
// reader.readAsDataURL(file);
reader.onload = function (e) {
console.log(e.target?.result);
var csvData = e.target?.result //This holding huge data
processCSVfile(csvData);
};
reader.readAsText(file);
event.target.value = null;
}
}
after processing in the store, I tried to pass that whole data to API, here I am facing issue as "Request URL is too long"
//Making api Get
//strData is holding whole CSV data
function getSampleCSV(strData: string) {
console.log("csvTest", strData);
return requests.get(`/ControllerName/SampleMethod/csvSample/${strData}`);
}