Class ViewAttachmentServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.atlassian.jira.web.servlet.viewfile.AbstractViewFileServlet
com.atlassian.jira.web.servlet.viewfile.ViewAttachmentServlet
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
- Direct Known Subclasses:
ViewTemporaryAttachmentServlet
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.atlassian.jira.web.servlet.viewfile.AbstractViewFileServlet
AbstractViewFileServlet.JwtAttachmentPermissionException
-
Field Summary
Fields inherited from class com.atlassian.jira.web.servlet.viewfile.AbstractViewFileServlet
IMAGE_ATTACHMENT_JWT_TOKEN_QUERY_PARAM_NAME, IMAGE_DISPLAYING_CANNOT_DISPLAY_IMAGE_PATH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected CommonAttachment
getCommonAttachment
(String query) protected int
getContentLength
(String attachmentPath) protected void
getInputStream
(javax.servlet.http.HttpServletRequest request, String attachmentQuery, InputStreamConsumer<io.atlassian.fugue.Unit> consumer) Gets the attachment file (not the file name) that corresponds to the requested attachment.protected void
setResponseContentHeaders
(javax.servlet.http.HttpServletRequest request, Optional<RangeResponse> rangeResponse, javax.servlet.http.HttpServletResponse response, Optional<Long> contentLength) Sets the content type, content length and "Content-Disposition" header of the response based on the values of the attachment found.protected boolean
Returns true if this implementation supports RFC 7233 "Range Requests".Methods inherited from class com.atlassian.jira.web.servlet.viewfile.AbstractViewFileServlet
attachmentQuery, checkRequesterIsPermittedToViewTheAttachment, copyRange, doGet, getAttachment, getAttachmentManager, getLoggedInUser, isAnonymousUserPermittedToViewAttachment, isImageAttachmentJwtTokenPresent, isJwtTokenUserPermittedToViewAttachment_andSendAnalyticsEvent, isLoggedInUserPermittedToViewAttachment, isUserLoggedIn, isUserPermittedToViewAttachment
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
-
Constructor Details
-
ViewAttachmentServlet
public ViewAttachmentServlet()
-
-
Method Details
-
getContentLength
- Specified by:
getContentLength
in classAbstractViewFileServlet
-
supportsRangeRequests
protected boolean supportsRangeRequests()Description copied from class:AbstractViewFileServlet
Returns true if this implementation supports RFC 7233 "Range Requests".Returning true means that you must set the appropriate "Content-Range" and "Content-Length" headers for the partial range we will return in the
#setResponseHeaders
implementation.- Specified by:
supportsRangeRequests
in classAbstractViewFileServlet
- Returns:
- true if this servlet supports RFC 7233 "Range Requests".
-
getInputStream
protected void getInputStream(javax.servlet.http.HttpServletRequest request, String attachmentQuery, InputStreamConsumer<io.atlassian.fugue.Unit> consumer) throws IOException, PermissionException Description copied from class:AbstractViewFileServlet
Gets the attachment file (not the file name) that corresponds to the requested attachment.- Specified by:
getInputStream
in classAbstractViewFileServlet
attachmentQuery
- the attachment pathconsumer
- a procedure that consumes the stream with the attachment data.- Throws:
IOException
- if there is a problem getting the attachment.PermissionException
-
setResponseContentHeaders
protected void setResponseContentHeaders(javax.servlet.http.HttpServletRequest request, Optional<RangeResponse> rangeResponse, javax.servlet.http.HttpServletResponse response, Optional<Long> contentLength) Sets the content type, content length and "Content-Disposition" header of the response based on the values of the attachment found.- Specified by:
setResponseContentHeaders
in classAbstractViewFileServlet
- Parameters:
request
- HTTP requestrangeResponse
- if we are doing a partial response this holds the range we will returnresponse
- HTTP responsecontentLength
- the length of the content we are returning in bytes, if known- Throws:
AttachmentNotFoundException
- if the specified attachment cannot be foundDataAccessException
- if there is a problem accessing the database.- See Also:
-
getCommonAttachment
-