To expose images over a public url we have created a JA with a custom request handler. In this request handler we an entity based on the path in the URL. Once the entity is retreived we use the Core method getImage() to get the contents of the image.
Following a simplyfied version of the code (This example does not work and is only for demo purpose...):
@Override
protected void processRequest(IMxRuntimeRequest req, IMxRuntimeResponse resp, String requestPath)
throws Exception {
HttpServletResponse response = resp.getHttpServletResponse();
IMendixObject entity = Core.retrieveXPathQueryEscaped(context, "//%s[%s='%s']", handler.getEntity(), "Name", params.get("Name"));
InputStream inputStream = Core.getImage(context, iMendixObject, false);
IOUtils.copy(inputStream, response.getOutputStream());
}
With the default filestorage service this works fine. Only with `com.mendix.core.StorageService` configured as `com.mendix.storage.s3` we get the following error:
Failed to serve GET books: com.mendix.systemwideinterfaces.MendixRuntimeException: com.amazonaws.services.s3.model.AmazonS3Exception: The specified key does not exist. (Service: Amazon S3; Status Code: 404; Error Code: NoSuchKey; Request ID: 0902549049DC04A4), S3 Extended Request ID: TP8V/SBl3/i2yPfQyubjeBNDj7t/QvCug/GZShAPu27LLS9cTMi83IZHykqZvjng/AoTrIhqM9I=
This while the file does exist on S3.
If anyone knows how to work around this issue that would be great.