posted 6 years ago
I am planning on a design approach that I want to confirm or seek suggestions. I am new to REST WS. I need to build an application specific REST Web client from where I need to send a zip file and additional data to a REST web service server. This web service (server) is generic to multiple applications and in turn will load the file to a unix server.
The web server service will respond to the rest client with path of file stored and additional data.
I am using Spring framework and JAXRS RestEasy
At Application REST Client:
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.MULTIPART_FORM_DATA)
public Response transferFile(
@FormDataParam("file") File fileInputStream,
@FormDataParam("file") FormDataContentDisposition contentDispositionHeader,
ModelClass1 class1);
@GET
@Consumes(MediaType.APPLICATION_JSON)
public Response transferStatus(ModelClass2 class2);
At Generic Web Service
@GET
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response downloadFileonWebServer(
@FormDataParam("file") File fileInputStream,
@FormDataParam("file") FormDataContentDisposition contentDispositionHeader,
ModelClass1 class1);
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.MULTIPART_FORM_DATA)
public ModelStatus2 uploadFiletoUnix(
@FormDataParam("file") File fileInputStream,
@FormDataParam("file") FormDataContentDisposition contentDispositionHeader,
ModelClass1 class1);
Also wanted to know:
Pros and Cons to send file as byte[] or zip file in the parameters
Do I need to save the file on the Web service server and then again stream to unix server or any other better suggestion
Do I need Response as return type or can I use VOID
FYI:
@Consumes on Application REST Client is to get data from the generic web service about path of file stored etc
File will be of size 10MB+
ModelClass1 - attributes: Folder name, additional data
ModelClass2 - attributes: path of unix server, additional data