Package com.levigo.jadice.server.rest
Class FileService
- java.lang.Object
-
- com.levigo.jadice.server.rest.FileService
-
@Path("/files/") public class FileService extends Object
This bean provides the REST service retrieve and store documents. It handles the REST specific part but delegates the content retrieval and storage to a backingContentStore
implementation.Please consult the swagger documentation for further details about the methods exposed via REST.
- Since:
- jadice server 5.6.0.0
-
-
Constructor Summary
Constructors Constructor Description FileService(ContentStore contentStore)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StreamDescriptor
buildStreamDescriptor(org.apache.cxf.jaxrs.ext.multipart.Attachment att)
Build aStreamDescriptor
that contains the filename, MIME type and description based on theAttachment
's header fields.void
deleteFile(String fileId, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Delete a file from the REST service.ContentStore
getContentStore()
InputStream
retrieveFile(String fileId, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Download a file from the REST servicevoid
setContentStore(ContentStore contentStore)
Set the backingContentStore
implementationString
storeFile(org.apache.cxf.jaxrs.ext.multipart.Attachment file, javax.servlet.http.HttpServletResponse response)
Upload a file to the REST service.
-
-
-
Constructor Detail
-
FileService
public FileService(ContentStore contentStore)
-
-
Method Detail
-
storeFile
@POST @Consumes({"multipart/form-data","application/x-www-form-urlencoded"}) @Produces("text/plain") public String storeFile(org.apache.cxf.jaxrs.ext.multipart.Attachment file, @Context javax.servlet.http.HttpServletResponse response) throws Exception
Upload a file to the REST service.- Throws:
Exception
-
buildStreamDescriptor
protected StreamDescriptor buildStreamDescriptor(org.apache.cxf.jaxrs.ext.multipart.Attachment att)
Build aStreamDescriptor
that contains the filename, MIME type and description based on theAttachment
's header fields.- Parameters:
att
- the Attachment to handle- Returns:
- a
StreamDescriptor
that contains the relevant information
-
retrieveFile
@GET @Path("{fileId}") @Produces("application/octet-stream") public InputStream retrieveFile(@PathParam("fileId") String fileId, @Context javax.servlet.http.HttpServletRequest request, @Context javax.servlet.http.HttpServletResponse response) throws IOException
Download a file from the REST service- Throws:
IOException
-
deleteFile
@DELETE @Path("{fileId}") public void deleteFile(@PathParam("fileId") String fileId, @Context javax.servlet.http.HttpServletRequest request, @Context javax.servlet.http.HttpServletResponse response) throws IOException
Delete a file from the REST service.- Throws:
IOException
-
getContentStore
public ContentStore getContentStore()
- Returns:
- the backing
ContentStore
implementation
-
setContentStore
public void setContentStore(ContentStore contentStore)
Set the backingContentStore
implementation
-
-