Jemie
Jemie

Reputation: 35

How to store content in a Hybris Media file?

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

Answers (1)

mkysoft
mkysoft

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

Related Questions