use of me.desair.tus.server.exception.TusException in project servoy-client by Servoy.
the class TusServlet method service.
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
tusFileUploadService.process(req, resp);
String uploadURI = req.getRequestURI();
UploadInfo uploadInfo = null;
try {
uploadInfo = this.tusFileUploadService.getUploadInfo(uploadURI);
} catch (IOException | TusException e) {
e.printStackTrace();
}
if (uploadInfo != null && !uploadInfo.isUploadInProgress()) {
try {
Path uploadedPath = this.tusFileUploadService.getUploadedPath(uploadURI);
File file = uploadedPath.toFile();
TusFileItem fileItem = new TusFileItem(file, uploadInfo, uploadURI);
AbstractMediaResourceServlet.FILE_CLEANING_TRACKER.track(file, file, new TusFileDeleteStategy(fileItem));
String path = req.getPathInfo();
if (path.startsWith("/"))
path = path.substring(1);
String[] paths = path.split("/");
int clientnr = paths[1].length() == 0 ? -1 : Integer.parseInt(paths[1]);
final INGClientWebsocketSession wsSession = getSession(req, clientnr);
if (wsSession != null) {
// clear out the tus id that is the last path entry (so it is not confused with the row id)
paths[paths.length - 1] = null;
JSMap<String, String> map = new JSMap<>();
map.putAll(uploadInfo.getMetadata());
callClient(req, paths, wsSession, map, fileItem);
}
} catch (IOException | TusException e) {
Debug.error(e);
}
}
}
Aggregations