Skip to content

[Bug]uploadInfo.isUploadInProgress() always be true even the uploading has finished #25

Description

@softboy99

@controller
@RequestMapping("/upload")
public class FileUploadController {
@value("${tus.server.data.directory}")
protected String tusDataPath;

@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();
    }
}

}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions