FAQ Database Discussion Community


Limit path media type mappings in Jersey

java,jersey,mapping,jersey-2.0,media-type
I have configured MEDIA_TYPE_MAPPINGS for my Jersey apps. Unfortunately, this causes some trouble with a generic upload service in my app. @PUT @Path("files/{filename}") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public Response uploadFile( @PathParam("filename") @NotNull @Size(max = 240) String filename, DataSource dataSource) If someone uploads .../files/file.xml the extension is chopped of. Is there...

Restlet using custom media type

java,json,restlet,restlet-2.0,media-type
In Restlet 2.3 (SE) I am trying to use media types to control versions. My current attempt involves registering new extensions in my inbound route: @Override public Restlet createInboundRoot() { ... getTunnelService().setExtensionsTunnel(true); getMetadataService().addExtension("vnd.myapp.v1", MediaType.valueOf("application/vnd.myapp.v1+json")); getMetadataService().addExtension("vnd.myapp.v2", MediaType.valueOf("application/vnd.myapp.v2+json")); ... } My resource interface is then setup as follows: public interface UsersResource {...

How to upload binary file(Photos etc ) with Meta Data using REST

rest,jersey,media-type
One way of doing is to convert the binary data to Base64 and send it along with meta data as MediaType.APPLICATION_JSON. The problem with this is client has to convert the binary data into Base64 before sending. I also tried sending using MediaType.APPLICATION_OCTET_STREAM format through REST. This works fine for...

Restlet Content Type Negotiation

java,mime-types,content-type,restlet,media-type
It's common for APIs to support various forms of content negotiation: Accept HTTP header on the Request, Content-Type HTTP header on the Request (although I don't think conforms to standards), and deriving the expected type from the file extension. I'd like my Restlet REST API to support all of these,...