Skip to Main Content

Ejb with rest service to upload / update blob

DLopezAug 19 2015 — edited Sep 3 2015

Hi,

I have successfully use a rest service to present an image saved in my DB as a BLOB, but now I have to do the opposite, upload one image and save it as blob, replacing the older one or adding a new one.

I thought that I could implement the same way that I use to update other data like strings, numbers and dates:

    @POST

    @Consumes("application/xml")

    @Path("/merge/")

    public Response update(Customer customer) {

       

        Customer persistedCustomerRecord = SessionBean.getCustomerFindByRecId(customer.getRecid()).get(0);

        if (persistedCustomerRecord != null) {

       

            persistedCustomerRecord.setFname(customer.getFname());

            persistedCustomerRecord.setMname(customer.getMname());

            persistedCustomerRecord.setName(customer.getName());

            persistedCustomerRecord.setAnniversdate(customer.getAnniversdate());

     

            SessionBean.mergeCustomer(persistedCustomerRecord);

        } else {

            throw new ResourceNotFoundException("The employee resource with the id " + customer.getRecid() + "could not be found");

        }

        return Response.ok().build();

    }

but when I test my service the input field for my memo appears has base64Binary and there isn't a 'button' like calendar to select the file.

With this in mind I guess I have to somehow allow the upload, selecting the file and convert it as byte[], since it's the type of data defined by EJB when creating the Entity from Table.

Am I right?

How can I accomplish this?

I'm using jdev 12c and EJB

Thanks

This post has been answered by DLopez on Aug 25 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on Sep 22 2015
Added on Aug 19 2015
6 comments
716 views