Import media using impex in Hybris

Hybris Logo

1. Overview

In this article, I will show you the different ways to import media using impex.

In Hybris there are 4 ways to import the media using impexes : absolute path, JAR based path, ZIP based path and URL based path.

The MediaDataTranslator.class determines the type of the path based on it’s prefix.

1.1. Absolute Path

The Absolute path starts with file: as a prefix.

$siteResource=file:C:\hybris\data\images


INSERT_UPDATE Media	;...;@media[translator=de.hybris.platform.impex.jalo.media.MediaDataTranslator];mime[default='image/jpeg']
					;...;$siteResource/hello.jpg

1.2. JAR based path

The JAR based path starts with jar: and composed of two parts separated by & : a class loader name and a media relative path.

E.g : For a media called hello.jpg located in resources/yinitialdata/images directory of the yinitialdata extension.

## For this example the Class loader is : com.stackextend.initialdata.setup.initialdatasystemsetup

$siteResource=jar:com.stackextend.initialdata.setup.initialdatasystemsetup&/yinitialdata/images


INSERT_UPDATE Media	;...;@media[translator=de.hybris.platform.impex.jalo.media.MediaDataTranslator];mime[default='image/jpeg']
					;...;$siteResource/hello.jpg

1.3. ZIP based path

The ZIP based path starts with zip: and composed of two parts separated by & : the path to the Zip file and the path to Zip entry.

E.g : For a Zip file called myFile.zip, and contains a file (entry) called hello.jpg.

$siteResource=zip:C:/hybris/test


INSERT_UPDATE Media	;...;@media[translator=de.hybris.platform.impex.jalo.media.MediaDataTranslator];mime[default='image/jpeg']
					;...;$siteResource/myFile.zip&hello.jpg

1.4. URL based path

For a media with the URL : http://www.example.com/medias/sys_master/images/images/hfb/hb6/9013544943646/hello.jpg

INSERT_UPDATE Media	;...;@media[translator=de.hybris.platform.impex.jalo.media.MediaDataTranslator];mime[default='image/jpeg']
					;...;http://www.example.com/medias/sys_master/images/images/hfb/hb6/9013544943646/hello.jpg

 

5 2 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Andi
Andi
5 years ago

Realy great article, helped me a lot. However i would have one question: How can i import from a folder, without having to name every image in that folder? How could i just import all images from one directory, and let ImpEx take the images filename as the name for hybris? As per your article we always turn in the filename: ;…;$siteResource/hello.jpg Is there a way to emit the “/hello.jpg” part? Because, when i want to import just a lot of images, i don’t want to type in the name of every single one into the impex 🙁 I can’t… Read more »

Sarmista
Sarmista
5 years ago

Hi I uploaded the media by importing the files through backoffice but images are not reflecting in application.
Can anyone help me out regarding this?

Arshad M
Arshad M
5 years ago

Does the Impex format support an escape syntax. If some data has an embedded semicolon or a newline, how can that be escaped.

3
0
Would love your thoughts, please comment.x
()
x