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

 

3
Leave a Reply

avatar
3 Comment threads
0 Thread replies
3 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
Arshad MSarmistaAndi Recent comment authors

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

  Subscribe  
newest oldest most voted
Notify of
Andi
Guest
Andi

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
Guest
Sarmista

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
Guest
Arshad M

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