0

Get Byte data from Image after using setSrc

asked 2016-06-08 18:16:24 +0800

ansancle gravatar image ansancle
327 9

I want to get the byte[] data for an image that was created from a relative image path and setSrc(imagePath), but I can't use Image.getContent() since that returns null.

I am setting the image into the object using image.setSrc("/relativeFilePathToImage") I know I can create an AImage but only if I have the full path to the file, which I don't have. Is there another way to construct the image using a relative image path or using a different class that will allow me to extract the image as a byte[]?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-06-11 09:51:07 +0800

longdv1208 gravatar image longdv1208
98 4

This can help you be not.

<button label="Upload Image" onupload="@command('onUploadImg',media=event.media)" upload="true,maxsize=1000"/> @Command("onUploadImg") public void onUploadImg(@BindingParam("media") Media media) { try { if (media instanceof Image) { byte [] a = media.getByteData(); } } catch (Exception e) { CommonException.error(e); } }

    @Command("onUploadImg")
public void onUploadImg(@BindingParam("media") Media media) {
    try {
        if (media instanceof Image) {
            byte [] a = media.getByteData();
        }
    } catch (Exception e) {
        CommonException.error(e);
    }
}
link publish delete flag offensive edit
0

answered 2016-06-11 14:27:56 +0800

Darksu gravatar image Darksu
1991 1 4

Hello ansancle,

Also please check out the following forum post:

http://forum.zkoss.org/question/95645/how-to-get-image-lob-attribute-from-database-into-listcell/

Best Regards,

Darksu

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2016-06-08 18:16:24 +0800

Seen: 20 times

Last updated: Jun 11 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More