Package sk.iway.iwcm.admin.upload
Class AdminUploadServlet
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
sk.iway.iwcm.admin.upload.AdminUploadServlet
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
@WebServlet("/admin/upload/chunk")
public class AdminUploadServlet
extends jakarta.servlet.http.HttpServlet
Receives administrative uploads in chunks, validates their destination, and assembles them.
Completed uploads are either written directly to an approved folder or retained temporarily
for a subsequent conflict-resolution request.
- See Also:
-
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleandeleteTempFile(String fileKey) Deletes a temporary upload that is no longer needed.protected voiddoPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Validates and stores one upload chunk, assembling and processing the file after the final chunk.static StringgetOriginalFileName(String fileKey) Returns the original name of a temporary upload.static StringgetTempFilePath(String fileKey) Returns the physical path of a temporary upload for validation by downstream consumers.static StringmoveAndReplaceFile(String fileKey, String destinationFolder, String fileNameParam) Moves a temporary upload to its final destination, replacing an existing file if necessary.Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPatch, doPut, doTrace, getLastModified, init, isSensitiveHeader, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
AdminUploadServlet
public AdminUploadServlet()
-
-
Method Details
-
doPost
protected void doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException Validates and stores one upload chunk, assembling and processing the file after the final chunk. File archive requests also preserve their validated bulk metadata across all chunks.- Overrides:
doPostin classjakarta.servlet.http.HttpServlet- Parameters:
request- multipart upload requestresponse- response receiving the JSON upload status- Throws:
jakarta.servlet.ServletException- when the servlet container cannot process the multipart requestIOException- when request data cannot be read or the response cannot be written
-
moveAndReplaceFile
public static String moveAndReplaceFile(String fileKey, String destinationFolder, String fileNameParam) throws IOException Moves a temporary upload to its final destination, replacing an existing file if necessary.- Parameters:
fileKey- unique key of the temporary uploaddestinationFolder- virtual path of the destination folder, for example/images/gallery/fileNameParam- requested destination file name- Returns:
- the final file name, or
nullwhen the temporary file was not moved - Throws:
IOException- when the file cannot be moved
-
deleteTempFile
Deletes a temporary upload that is no longer needed.- Parameters:
fileKey- unique key of the temporary upload- Returns:
truewhen the temporary file existed and was deleted
-
getTempFilePath
Returns the physical path of a temporary upload for validation by downstream consumers.- Parameters:
fileKey- unique key of the temporary upload- Returns:
- temporary file path, or
nullwhen the key is unknown
-
getOriginalFileName
Returns the original name of a temporary upload.- Parameters:
fileKey- unique key of the temporary upload- Returns:
- original file name, or
nullwhen the key is unknown
-