I have the following web service that works just fine. I need to add the capability to upload a file along with the instance of TrackBean that is serialized into JSON.
I've found a lot of examples of just file uploads but none that would accept json and a file within the same post.
Is it bad technique to do this all at once? Would it be a better practice to upload the file first, get some sort of token from the server as a response and then send the json in a second post, referencing the token from post #1 so the server would know which file to associate with the incoming JAXB_TrackBean instance.
Thanks in advance for the help!
webservice chunk:
@POST
@Path( "/post" )
@Consumes( MediaType.APPLICATION_JSON )
public Response createTrackInJSON( JAXB_TrackBean track )
{
String result = "TrackBean saved : " + track.getText() ;
return Response.status( 201 ).entity( result ).build();
}
JAXB_TrackBean:
@XmlRootElement( name = "track" )
@XmlType( propOrder = { "id", "text" } )
public class JAXB_FtTextBean
{
private long id = 0;
private String text;
// getter/setters omitted for brevity
}