@Shiva already answered might helpful for using .NET CIL.
To get the Binary using Java CIL.
Java Example:
import com.sdl.web.api.dynamic.BinaryContentRetrieverImpl;
import com.sdl.web.api.dynamic.DynamicMetaRetrieverImpl;
import com.tridion.data.BinaryData;
import com.tridion.dynamiccontent.DynamicMetaRetriever;
import com.tridion.meta.BinaryMeta;
import com.sdl.web.api.content.BinaryContentRetriever;
import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
public class SDLCILTest {
public static void main(String[] args) throws Exception {
DynamicMetaRetriever dynamicMetaRetriever = new DynamicMetaRetriever();
String urlPath = "/media/map_tcm5-316.jpg";
String path = "c://temp/test.jpg";
final File file = new File(path);
BinaryMeta binaryMeta = dynamicMetaRetriever.getBinaryMetaByURL(urlPath);
int itemId = (int) binaryMeta.getURI().getItemId();
int publicationId = 5;
//WebComponentMetaFactory factory = new WebComponentMetaFactoryImpl(publicationId);
//ComponentMeta componentMeta = factory.getMeta(itemId);
//long componentTime = componentMeta.getLastPublicationDate().getTime();
//TODO based on component metadata date modified - fetch only if file is modified
BinaryContentRetriever binaryContentRetriever = new BinaryContentRetrieverImpl();
BinaryData binaryData = binaryContentRetriever.getBinary(publicationId, itemId, binaryMeta.getVariantId());
try {
Files.write(binaryData.getBytes(), file);
} catch (IOException e) {
throw new Exception("Cannot write new loaded content to a file " + file, e);
}
}
}
For some DXA references for CIL to download Binary could be useful for you.
CilStaticContentResolver.java
GenericStaticContentResolver.java
For Microservices URLs for your reference how that CIL API's get converted to get the Binaries, you can play around with the postman.
http://localhost:8081/client/v4/content.svc/GetDynamicMetaFunctionImport(Url='%252Fmedia%252Fmap_tcm5-316.jpg',ItemType='BinaryMeta')
http://localhost:8081/client/v2/content.svc/BinaryContents(PublicationId=5,BinaryId=316,VariantId=WyNkZWYjXQ==,StreamContent=false)
http://localhost:8081/client/v2/content.svc/BinaryContents(BinaryId=316,PublicationId=5,VariantId='ZGVmYXVsdA==')/$value
I hope it helps.