@Autowired
private TusFileUploadService tusFileUploadService;
@Autowired
private FileUploadService fileUploadService;
//@CrossOrigin(origins = "http://127.0.0.1:8080",exposedHeaders = {"Location","Upload-Offset","Upload-Length"})
@RequestMapping(value = {"", "/**"}, method = {RequestMethod.POST, RequestMethod.PATCH, RequestMethod.HEAD,
RequestMethod.DELETE, RequestMethod.OPTIONS, RequestMethod.GET})
public void processUpload(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) {
// tusFileUploadService.withUploadURI(servletRequest.getContextPath() + "/upload");
try {
tusFileUploadService.process(servletRequest, servletResponse);
String hLocation = servletResponse.getHeader(HttpHeader.LOCATION);
if(hLocation!=null){
while(true){
UploadInfo ui = tusFileUploadService.getUploadInfo(hLocation);
if(ui!=null && !ui.isUploadInProgress()) {
InputStream uploadedBytes = tusFileUploadService.getUploadedBytes(hLocation);
///////////////////////////// others code here
break;
}
}
}
} catch (IOException | TusException e) {
e.printStackTrace();
}
}
@controller
@RequestMapping("/upload")
public class FileUploadController {
@value("${tus.server.data.directory}")
protected String tusDataPath;
}