Translation Framework: cannot get preview file | Community
Skip to main content
Level 2
January 19, 2024
Solved

Translation Framework: cannot get preview file

  • January 19, 2024
  • 2 replies
  • 1187 views

I am trying to get the preview file while using the translation integration framework.

I am using the code provided in the Bootstrap Connector (https://github.com/Adobe-Marketing-Cloud/aem-translation-framework-bootstrap-connector).

Here's the specific code parts:

(in the uploadTranslationObject() function)

 

 

// Generate Preview if(isPreviewEnabled) { try { ZipInputStream zipInputStream = translationObject.getTranslationObjectPreview(); if (zipInputStream != null) { unzipFileFromStream(zipInputStream, previewPath); } else { log.error("Got null for zipInputStream for " + getObjectPath(translationObject)); } } catch (FileNotFoundException e) { log.error(e.getLocalizedMessage(), e); } catch (IOException e) { log.error(e.getLocalizedMessage(), e); } } log.trace("Preview Directory is: {}", previewPath);

 

 
also

 

 

private static void unzipFileFromStream(ZipInputStream zipInputStream, String targetPath) throws IOException { File dirFile = new File(targetPath + File.separator); if (!dirFile.exists()) { dirFile.mkdirs(); log.trace("Created directory: {}",dirFile); } ZipEntry zipEntry = null; while (null != (zipEntry = zipInputStream.getNextEntry())) { String zipFileName = zipEntry.getName(); if (zipEntry.isDirectory()) { File zipFolder = new File(targetPath + File.separator + zipFileName); if (!zipFolder.exists()) { zipFolder.mkdirs(); log.trace("Created directory: {}",zipFolder); } } else { File file = new File(targetPath + File.separator + zipFileName); File parent = file.getParentFile(); if (!parent.exists()) { parent.mkdirs(); } FileOutputStream fos = null; try { fos = new FileOutputStream(file); } catch (FileNotFoundException e) { log.error(e.getLocalizedMessage(),e); } int readLen = 0; byte buffer[] = new byte[1024]; while (-1 != (readLen = zipInputStream.read(buffer))) { fos.write(buffer, 0, readLen); } fos.close(); } } zipInputStream.close(); }

 

 
I've added some extra logging and it seems the specified folder was created but after checking it in CRXDE there is no such folder.
How this should work? Is there a specific folder where the preview needs to be saved?
Or is it even a working code example?

Thanks in advance!
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by EstebanBustamante

I meant if the target path is not in the server (OS) paths like: "/mnt/crx" if you are on linux OR "c://somefolder" in windows. Is this an AEM path?

2 replies

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
January 22, 2024

Can you check what is the value of the "targetPath" parameter? I am wondering if the file is not being generated in the server where AEM is installed and not necessarily in AEM.

Esteban Bustamante
Level 2
January 23, 2024

I tried with a few paths, none was working. Like saving in tmp folder (/tmp/bootstrap-tms/previews/) or in var (/var/bootstrap-tms/20240119/previews). The bootstrap service has jcr:all permission on these folders.

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
January 23, 2024

I meant if the target path is not in the server (OS) paths like: "/mnt/crx" if you are on linux OR "c://somefolder" in windows. Is this an AEM path?

Esteban Bustamante
kautuk_sahni
Community Manager
Community Manager
January 29, 2024

@thebestusernameifound Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni