You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Bhavesh Bhanushali <b....@gmail.com> on 2010/10/28 15:50:57 UTC

Images problem in jackrabbit

Hi,

I am newbie in using jackrabbit, I am facing a strange issue when i am
storing and retrieving images from jackrabbit. The text in the images
fetched are garbled and size is reduced.

I apologize if i am sending to wrong mailing list. I tried to subscribe to
user's mailing list but it is throwing errors.

Meanwhile, here is the strange problem.

The image is stored into jackrabbit by using following piece of code

-----
 Node fileNode = contentNode.addNode(content.getFileName(),
NodeType.NT_FILE);
                                Node _fileContentNode =
fileNode.addNode(JcrConstants.JCR_CONTENT, NodeType.NT_RESOURCE);

 _fileContentNode.setProperty(JcrConstants.JCR_MIMETYPE,
content.getMimeType());

 _fileContentNode.setProperty(JcrConstants.JCR_DATA,
ValueFactoryImpl.getInstance().createBinary(new
ByteArrayInputStream(IOUtils.toByteArray(content.getFile().getInputStream()))));
                                 session.save();
-----

when i retrieve the image using the proper path, the image is fetched with
no problem but the text of the image is garbled and is not readable.

Please refer attachment, actual image uploaded is
"math_eq1_to_repository.png" and fetched image is
"math_eq1_from_repository.png"

Same thing happens with GIF and JPEG images.

I am not sure what is the wrong in the above code.

Request you all to help me to fix this strange issue.

Jackrabbit version used is 2.1.0

Thanks,
Bhavesh R Bhanushali

Re: Images problem in jackrabbit

Posted by Bhavesh Bhanushali <b....@gmail.com>.
Thanks for replying,

The reason i am not passing stream directly is i have to explode zip file
directly into the content repository.

While i exploding zipStream i already have contents in the memory and to
avoid extra overhead of writing contents to file system and than storing
back into repository.

There is one more reason I cannot explode zip file into temporary folder and
than write into repository again is due to cloud architecture constraints.

I will surely try the workaround suggested by you people.

Thanks,
Bhavesh R Bhanushali

On Thu, Oct 28, 2010 at 7:30 PM, Stefan Guggisberg <
stefan.guggisberg@day.com> wrote:

> On Thu, Oct 28, 2010 at 3:50 PM, Bhavesh Bhanushali
> <b....@gmail.com> wrote:
> > Hi,
> >
> > I am newbie in using jackrabbit, I am facing a strange issue when i am
> > storing and retrieving images from jackrabbit. The text in the images
> > fetched are garbled and size is reduced.
> >
> > I apologize if i am sending to wrong mailing list. I tried to subscribe
> to
> > user's mailing list but it is throwing errors.
> >
> > Meanwhile, here is the strange problem.
> >
> > The image is stored into jackrabbit by using following piece of code
> >
> > -----
> >  Node fileNode = contentNode.addNode(content.getFileName(),
> > NodeType.NT_FILE);
> >                                 Node _fileContentNode =
> > fileNode.addNode(JcrConstants.JCR_CONTENT, NodeType.NT_RESOURCE);
> >
> >  _fileContentNode.setProperty(JcrConstants.JCR_MIMETYPE,
> > content.getMimeType());
> >
> >  _fileContentNode.setProperty(JcrConstants.JCR_DATA,
> > ValueFactoryImpl.getInstance().createBinary(new
> >
> ByteArrayInputStream(IOUtils.toByteArray(content.getFile().getInputStream()))));
>
> just a detail, but ...  why don't you pass the stream directly?
>
> e.g.
> InputStream stream = content.getFile().getInputStream();
> try {
>     _fileContentNode.setProperty(JcrConstants.JCR_DATA,
> ValueFactoryImpl.getInstance().createBinary(stream));
> } finally {
>    IOUtils. closeQuietly(stream);
> }
>
> cheers
> stefan
>
> >                                  session.save();
> > -----
> >
> > when i retrieve the image using the proper path, the image is fetched
> with
> > no problem but the text of the image is garbled and is not readable.
> >
> > Please refer attachment, actual image uploaded is
> > "math_eq1_to_repository.png" and fetched image is
> > "math_eq1_from_repository.png"
> >
> > Same thing happens with GIF and JPEG images.
> >
> > I am not sure what is the wrong in the above code.
> >
> > Request you all to help me to fix this strange issue.
> >
> > Jackrabbit version used is 2.1.0
> >
> > Thanks,
> > Bhavesh R Bhanushali
> >
> >
> >
> >
>

Re: Images problem in jackrabbit

Posted by Stefan Guggisberg <st...@day.com>.
On Thu, Oct 28, 2010 at 3:50 PM, Bhavesh Bhanushali
<b....@gmail.com> wrote:
> Hi,
>
> I am newbie in using jackrabbit, I am facing a strange issue when i am
> storing and retrieving images from jackrabbit. The text in the images
> fetched are garbled and size is reduced.
>
> I apologize if i am sending to wrong mailing list. I tried to subscribe to
> user's mailing list but it is throwing errors.
>
> Meanwhile, here is the strange problem.
>
> The image is stored into jackrabbit by using following piece of code
>
> -----
>  Node fileNode = contentNode.addNode(content.getFileName(),
> NodeType.NT_FILE);
>                                 Node _fileContentNode =
> fileNode.addNode(JcrConstants.JCR_CONTENT, NodeType.NT_RESOURCE);
>
>  _fileContentNode.setProperty(JcrConstants.JCR_MIMETYPE,
> content.getMimeType());
>
>  _fileContentNode.setProperty(JcrConstants.JCR_DATA,
> ValueFactoryImpl.getInstance().createBinary(new
> ByteArrayInputStream(IOUtils.toByteArray(content.getFile().getInputStream()))));

just a detail, but ...  why don't you pass the stream directly?

e.g.
InputStream stream = content.getFile().getInputStream();
try {
    _fileContentNode.setProperty(JcrConstants.JCR_DATA,
ValueFactoryImpl.getInstance().createBinary(stream));
} finally {
    IOUtils. closeQuietly(stream);
}

cheers
stefan

>                                  session.save();
> -----
>
> when i retrieve the image using the proper path, the image is fetched with
> no problem but the text of the image is garbled and is not readable.
>
> Please refer attachment, actual image uploaded is
> "math_eq1_to_repository.png" and fetched image is
> "math_eq1_from_repository.png"
>
> Same thing happens with GIF and JPEG images.
>
> I am not sure what is the wrong in the above code.
>
> Request you all to help me to fix this strange issue.
>
> Jackrabbit version used is 2.1.0
>
> Thanks,
> Bhavesh R Bhanushali
>
>
>
>

Re: Images problem in jackrabbit

Posted by Julian Reschke <ju...@gmx.de>.
On 28.10.2010 15:50, Bhavesh Bhanushali wrote:
> Hi,
>
> I am newbie in using jackrabbit, I am facing a strange issue when i am
> storing and retrieving images from jackrabbit. The text in the images
> fetched are garbled and size is reduced.
>
> I apologize if i am sending to wrong mailing list. I tried to subscribe
> to user's mailing list but it is throwing errors.
>
> Meanwhile, here is the strange problem.
> ...

If you compare the two images you'll see that apparently all bytes in 
the range 128-159 (C1 characters) got mangled.

Wild guess: somewhere there's an API involved that uses chars, not bytes...

Best regards, Julian