[Yanel-dev] Persisting binary data uploaded from a form

Michael Wechner michael.wechner at wyona.com
Thu Oct 7 18:18:17 CEST 2010


  Hi Ioannis

On 10/6/10 6:29 PM, Ioannis P. Iordanidis wrote:
> Hi,
>
> The resource type that I've written so far for the task of persisting =

> an Image asset to disk has focused on storing only the text metadata =

> of the image.
> These data are entered into a form by an editor.
>
> The approach has been to take the metadata from the request =

> parameters, build an xml document and write that to disk using the =

> XMLHelper class.
>
> Node newNode =3D YarepUtil.addNodes(repository, fullRepoPath, =

> NodeType.RESOURCE);
> newNode.setMimeType("application/xml");
> Document document =3D XMLHelper.createDocument(FOO_NAMESPACE, "Image");
> XMLHelper.writeDocument(createXmlAsset(document), =

> newNode.getOutputStream());
>
> where the createXMLAsset() method takes care of adding nodes to the =

> document, each populated from request parameter values.

ok
>
> Now my question is: Does anybody know a good approach for taking the =

> binary data of the uploaded image and persisting that as well?

It's two steps:

1) One is getting the data via the Request (and to determine its mime type)
2) Is persisting the data


Re 2) it is very similar to what you have done with the meta data,

Node newImageNode =3D YarepUtil.addNodes(repository, fullRepoPathOfImage, =

NodeType.RESOURCE);
newImageNode.setMimeType(image.imageMimeType());
org.apache.commons.io.IOUtils.copy(image.getInputStream(), =

newImageNode.getOutputStream());

whereas now the question what is "image" and what do the methods

image#getMimeType()
image#getInputStream()

do, whereas let me discuss within follow-up email, because I need to get =

offline
for a moment and am afraid that I am loosing this part ;-)

Will continue on it shortly.

Cheers

Michael


> As the form will have to be submitted using a multipart/form-data =

> content type, I am anticipating that the approach thus far will be =

> inadequate.
>
> Any help would be much appreciated.
> Cheers,
> Ioannis =


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wyona.org/pipermail/yanel-development/attachments/2010100=
7/062d8543/attachment.htm


More information about the Yanel-development mailing list