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
Modifier and TypeClassDescriptionstatic class
class
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Allow deletes on files.static final String
Allow uploads on files.static final String
Allow view and downloads on files.static final String
Root directory.Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.juneau.microservice.resources.DirectoryResource.RedirectToRoot
deleteFile
(String path) org.apache.juneau.microservice.resources.DirectoryResource.FileContents
downloadFile
(RestResponse res, String path) getFile
(RestRequest req, String path) protected File
Returns the root directory.org.apache.juneau.microservice.resources.DirectoryResource.RedirectToRoot
updateFile
(InputStream is, String path) org.apache.juneau.microservice.resources.DirectoryResource.FileContents
viewFile
(RestResponse res, String path) Methods inherited from class org.apache.juneau.rest.servlet.BasicRestServlet
error, getFavIcon, getHtdoc, getStats, getSwagger
Methods inherited from class org.apache.juneau.rest.servlet.RestServlet
destroy, doLog, getContext, getPath, getRequest, getResponse, init, log, log, service, setContext
Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
Methods 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
-
getFile
public DirectoryResource.FileResource getFile(RestRequest req, @Path("/*") String path) throws NotFound, Exception -
viewFile
public org.apache.juneau.microservice.resources.DirectoryResource.FileContents viewFile(RestResponse res, @Path("/*") String path) throws NotFound, MethodNotAllowed - Throws:
NotFound
MethodNotAllowed
-
downloadFile
public org.apache.juneau.microservice.resources.DirectoryResource.FileContents downloadFile(RestResponse res, @Path("/*") String path) throws NotFound, MethodNotAllowed - Throws:
NotFound
MethodNotAllowed
-
deleteFile
public org.apache.juneau.microservice.resources.DirectoryResource.RedirectToRoot deleteFile(@Path("/*") String path) throws MethodNotAllowed - Throws:
MethodNotAllowed
-
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
-
getRootDir
Returns the root directory.- Returns:
- The root directory.
-