public static void runExample(
DfaServices dfaServices, DfaSession session, String assetName, String pathToFile,
long creativeId) throws Exception {
// Request the creative service from the service client factory.
CreativeRemote creativeService = dfaServices.get(session, CreativeRemote.class);
// Create the In-Stream video creative asset.
CreativeAsset inStreamVideoAsset = new CreativeAsset();
inStreamVideoAsset.setName(assetName);
inStreamVideoAsset.setContent(Media.getMediaDataFromFile(pathToFile));
// Create an upload request to make this asset a media file for an existing
// In-Stream creative.
InStreamAssetUploadRequest inStreamAssetUploadRequest = new InStreamAssetUploadRequest();
inStreamAssetUploadRequest.setMediaFile(true);
inStreamAssetUploadRequest.setInStreamAsset(inStreamVideoAsset);
inStreamAssetUploadRequest.setCreativeId(creativeId);
// Save the media file.
InStreamVideoCreative inStreamVideoCreative =
creativeService.uploadInStreamAsset(inStreamAssetUploadRequest);
// Display a success message.
System.out.printf("Added a media file to In-Stream video creative with ID \"%s\".%n",
inStreamVideoCreative.getId());
}