Class FileServlet
java.lang.Object
io.github.qubitpi.athena.web.endpoints.FileServlet
Endpoint for POSTing files.
-
Constructor Summary
ConstructorDescriptionFileServlet
(@NotNull FileStore fileStore, @NotNull MetaStore metaStore) DI constructor. -
Method Summary
Modifier and TypeMethodDescription@NotNull jakarta.ws.rs.core.Response
downloadFile
(String fileId) Retrieves a file from object storage.@NotNull jakarta.ws.rs.core.Response
uploadFile
(@NotNull InputStream fileContent, @NotNull org.glassfish.jersey.media.multipart.FormDataContentDisposition fileMetaData) Persists a file to object storage.
-
Constructor Details
-
FileServlet
@Inject public FileServlet(@NotNull @NotNull FileStore fileStore, @NotNull @NotNull MetaStore metaStore) DI constructor.- Parameters:
fileStore
- A client connecting file data and persistence storagemetaStore
- A client connecting file metadata and persistence storage- Throws:
NullPointerException
- if any argument isnull
-
-
Method Details
-
uploadFile
@POST @NotNull @Path("/upload") @Produces("application/json") @Consumes("multipart/form-data") public @NotNull jakarta.ws.rs.core.Response uploadFile(@NotNull @NotNull InputStream fileContent, @NotNull @NotNull org.glassfish.jersey.media.multipart.FormDataContentDisposition fileMetaData) Persists a file to object storage.- Parameters:
fileContent
- The file contentfileMetaData
- The file metadata- Returns:
- a Json object indicating whether the request is successful or not
- Throws:
NullPointerException
- if any argument isnull
-
downloadFile
@GET @NotNull @Path("/download") @Produces("application/octet-stream") public @NotNull jakarta.ws.rs.core.Response downloadFile(@QueryParam("fileId") String fileId) Retrieves a file from object storage.- Parameters:
fileId
- TheID of the file
previously uploaded.- Returns:
- a file to be downloaded
- Throws:
NullPointerException
- iffileId
isnull
-