Class DirectoryResource
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.juneau.rest.servlet.RestServlet
org.apache.juneau.rest.servlet.BasicRestServlet
org.apache.juneau.microservice.resources.DirectoryResource
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable,BasicUniversalConfig,DefaultConfig,DefaultHtmlConfig,BasicRestOperations
REST resource that allows access to a file system directory.
The root directory is specified in one of two ways:
-
Specifying the location via a
DirectoryResource.rootDir property. -
Overriding the
getRootDir()method.
Read/write access control is handled through the following properties:
-
DirectoryResource.allowViews - Iftrue , allows view and download access to files. -
DirectoryResource.allowUploads - Iftrue , allows files to be created or overwritten. -
DirectoryResource.allowDeletes - Iftrue , allows files to be deleted.
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classclass -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAllow deletes on files.static final StringAllow uploads on files.static final StringAllow view and downloads on files.static final StringRoot directory.Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.juneau.microservice.resources.DirectoryResource.RedirectToRootdeleteFile(String path) org.apache.juneau.microservice.resources.DirectoryResource.FileContentsdownloadFile(RestResponse res, String path) getFile(RestRequest req, String path) protected FileReturns the root directory.org.apache.juneau.microservice.resources.DirectoryResource.RedirectToRootupdateFile(InputStream is, String path) org.apache.juneau.microservice.resources.DirectoryResource.FileContentsviewFile(RestResponse res, String path) Methods inherited from class org.apache.juneau.rest.servlet.BasicRestServlet
error, getFavIcon, getHtdoc, getStats, getSwaggerMethods inherited from class org.apache.juneau.rest.servlet.RestServlet
destroy, doLog, getContext, getPath, getRequest, getResponse, init, log, log, service, setContextMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, serviceMethods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
DIRECTORY_RESOURCE_rootDir
Root directory.- See Also:
-
DIRECTORY_RESOURCE_allowViews
Allow view and downloads on files.- See Also:
-
DIRECTORY_RESOURCE_allowDeletes
Allow deletes on files.- See Also:
-
DIRECTORY_RESOURCE_allowUploads
Allow uploads on files.- See Also:
-
-
Constructor Details
-
DirectoryResource
- Throws:
Exception
-
-
Method Details
-
deleteFile
public org.apache.juneau.microservice.resources.DirectoryResource.RedirectToRoot deleteFile(@Path("/*") String path) throws MethodNotAllowed - Throws:
MethodNotAllowed
-
downloadFile
public org.apache.juneau.microservice.resources.DirectoryResource.FileContents downloadFile(RestResponse res, @Path("/*") String path) throws NotFound, MethodNotAllowed - Throws:
NotFoundMethodNotAllowed
-
getFile
public DirectoryResource.FileResource getFile(RestRequest req, @Path("/*") String path) throws NotFound, Exception -
updateFile
public org.apache.juneau.microservice.resources.DirectoryResource.RedirectToRoot updateFile(@Content @Schema(type="string",format="binary") InputStream is, @Path("/*") String path) throws InternalServerError - Throws:
InternalServerError
-
viewFile
public org.apache.juneau.microservice.resources.DirectoryResource.FileContents viewFile(RestResponse res, @Path("/*") String path) throws NotFound, MethodNotAllowed - Throws:
NotFoundMethodNotAllowed
-
getRootDir
Returns the root directory.- Returns:
- The root directory.
-