In my project now, I need to store some images to Riak, then get them from Riak and display them in HTML page.
Here is an API I encapsulated:
//inputstream is a stream of an image
byte[] imageContent = IOUtils.toByteArray(inputStream);
String descriptiveId = null;
String storedImageId = UUID.randomUUID().toString();
BlobContent blobContent = new BlobContent(imageContent,descriptiveId);
riakBlobDAO.create(storedImageId,blobContent);
.....
//get the byte[] from riak by the uuid
BlobContent returnedBlobContent = riakBlobDAO.get(storedImageId);
byte[] returnedImageContent = returnedBlobContent.getData();
if i invoke this method,it will return sth,but for this <img src="xxxx">
,i can't
get the src from the returned sth, so any other solutions?
I know the image stored in riak is binary bytes, but I am confused that how can I get it from riak and display it in HTML page.
I know that <img src="xxxx" />
,but if an image stored in Riak,can i generate the image url ?