2

I'm trying to upload an image programmatically in aem. It is a simple jpeg, or png. I tried to create node by hand and I also tried using AssetManager.createAsset.

Image was created but workflows has failed. I get stacktraces in AEM logs (of course those are not full logs, just headers):

com.day.cq.dam.commons.handler.StandardImageHandler getImage: error while reading image at path
com.day.cq.dam.commons.handler.StandardImageHandler failed to extract image using Layer will try the fallback
javax.imageio.IIOException: No decoder available to load the image
com.day.cq.dam.core.impl.gfx.CommonsGfxRenderer gfx: cannot get image for asset
com.day.cq.dam.commons.handler.StandardImageHandler getImage: error while reading image at path [/content/dam/path/to/image/original]: 
org.apache.commons.imaging.ImageReadException: Can't parse this format.

Any ideas why this is happening? Workflows throws errors, thumbnails are not created, metadata are not extracted.

Ma Kro
  • 1,232
  • 4
  • 20
  • 34

2 Answers2

2

You are probably missing the jcr:mimeType property on the image node. Best might be to upload an image via WebDAV and check the node structure that this creates. Reproducing that structure programatically should work.

Bertrand Delacretaz
  • 6,100
  • 19
  • 24
2
Asset asset = assetManager.createAsset(damPath, in, dataMimeType, false);

Are your's dataMimeType correct? For example, It should be "image/jpeg"

Also may be useful : https://helpx.adobe.com/experience-manager/using/uploading-files-aem1.html

dzenisiy
  • 855
  • 10
  • 32