function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Akshay MhetreAkshay Mhetre 

Help me to write a test class

@RestResource(urlMapping='/multifileapi/*')
global with sharing class IND_MultipleFileUplaod_API
{
private static List<KV> keyValues;
@HttpPost
global static void doPost(){

Blob body = RestContext.request.requestBody;
String blobStr = EncodingUtil.base64Encode(body);

String encodedBoundary = blobStr.substring(0,blobStr.indexof('Q29udGVudC1EaXNwb3NpdGlvbjo'));

String actualBoundary = EncodingUtil.base64decode(encodedBoundary).toString().replace('\n','').replace('\r','');

String actualBody = EncodingUtil.base64decode(blobStr).toString().replace('\n','').replace('\r','');
actualBody = actualBody.replaceFirst(actualBoundary, '');
actualBody = actualBody.substring(0,actualBody.length()-2);

List<String> keyValueStr = actualBody.split(actualBoundary);
getKeyValue(keyValueStr);
RestResponse res = RestContext.response;
if (res == null) {
res = new RestResponse();
RestContext.response = res;
}
res.responseBody = Blob.valueOf(JSON.serialize(keyValues));
}

private static List<KV> getKeyValue(List<String> pairs){
keyValues = new List<KV>();
for(String s:pairs){
KV kv = new KV();
kv.key = s.substring(s.indexOf('\"')+1,s.lastIndexOf('\"'));
kv.value = s.substring(s.lastIndexOf('\"')+1);
kv.contentDisposition = s.substring(s.indexOf('Content-Disposition: ')+21,s.indexOf(';'));
keyValues.add(kv);
}
return keyValues;
}

private class KV{
String contentDisposition;
String key;
String value;

}
}
PriyaPriya (Salesforce Developers) 
Hey Akshay,

The developer community recommends providing any attempts/code you've started, any errors you're getting, or where exactly you're struggling in achieving this while posting a question.

Regards