Reputation: 35
In my application we are getting media like photos and Videos from third party and I want to store it in Hybris as a media ? How can we upload Photos/Videos through the java code in a Hybris Media?
Upvotes: 0
Views: 1472
Reputation: 5758
You can check my simple example. Not forget to add exception block. Check CatalogUnawareMedia and CatalogMedia before your implementation. If you are not planning to synchronize third-party objects use CatalogUnawareMedia.
// folder optional
final MediaFolderModel folder = mediaService.getFolder("myfolder");
final CatalogUnawareMediaModel media = getModelService().create(CatalogUnawareMediaModel.class); //or CatalogMediaModel
media.setCode(myFileName);
media.setFolder(folder);
getModelService().save(media);
mediaService.setStreamForMedia(media, myStream);
getModelService().save(media);
Upvotes: 1