I am trying to programmatically download an image and store it in the
repository.
Also I would like to do it the >4.5 way.
What I have so far looks like
[code] URL imageUrl = new URL(url, imageSource);
URLConnection uCon = imageUrl.openConnection();
String mimeType = uCon.getContentType();
InputStream is = uCon.getInputStream();
Session session =
MgnlContext.getJCRSession(RepositoryConstants.WEBSITE);
ValueFactory valueFactory = session.getValueFactory();
Binary binary = valueFactory.createBinary(is);
if (!content.hasProperty("image")) {
content.setProperty("image", binary);
} else {
content.getProperty("image").setValue(binary);
}
[/code]
The node is created, but seems to be empty.
Also I don't know how to set the mime type.
Kind regards
Tobias Reinhardt
--
Context is everything:
http://forum.magnolia-cms.com/forum/thread.html?threadId=3c12a79f-6909-469c-9f93-2f982920aabc
----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------