users@jersey.java.net

[Jersey] Design Question, Image upload and download

From: Robert DiFalco <robert.difalco_at_gmail.com>
Date: Tue, 11 Nov 2014 09:04:22 -0800

This is more of a design question. We have a mobile app where users have
friends much like Facebook. They can attach a photo to their profile. When
they look at friends they can see their friends profile photo.

Right now the Jersey server is located on Heroku which does not have file
storage, so I will need to physically store the images in something like S3
or CacheFly.

In designing the JAX-RS interface I am wondering the best way to (a) create
the request that allows the user to upload the image and (b) the request
that returns users or friends from the database along with their images.

I'm thinking for (b) I just return a JSON of each user with a field that
has a direct link to wherever I will store the photos (CacheFly, S3, or
other).

For (a) I'm not sure the right approach. Should I be using @Consumes(
MediaType.MULTIPART_FORM_DATA)? Then stream this quickly to my CDN so I
don't tie up my REST server? Is there a way to use ASYNC for this?

If you know of any blogs that address this (even the storing of the photos
to a CDN or external storage along with Jersey) please send them over to
me. I'm sure I can figure this out but wanted to learn as much as I could
before designing the solution for my mobile clients. Thanks!