How can i upload a file from my client PC via Apex ? I need it for a test class so i cannot make api callout.
I try this but without success
String yourFiles = 'Lets assume this is your binary string of the files';
ContentVersion conVer = new ContentVersion();
conVer.ContentLocation = 'E'; // S specify this document is in SF, use E for external files
conVer.PathOnClient = 'C:\myPC\Accounts1472.csv'; // The files name, extension is very important here which will help the file in preview.
conVer.Title = 'Accounts1472 '; // Display name of the files
conVer.VersionData = EncodingUtil.base64Decode(yourFiles); // converting your binary string to Blog
insert conVer;
Any suggestions please ?
Best Answer
I solved the issue by doing the following: 1) Get to https://onlinecsvtools.com/convert-csv-to-base64 and convert the content of my CSV 2) Since i did not find solution to insert directly from my client pc i used the Salesforce ContentLocation but i inserted my content.