tomdesair / tus-java-server

Library to receive tus v1.0.0 file uploads in a Java server environment
MIT License
128 stars 60 forks source link

file getUploadedBytes UploadNotFoundException. #59

Open AdityaKBhadragond14 opened 1 year ago

AdityaKBhadragond14 commented 1 year ago

Expected Behaviour

To get the uploaded bytes using the tusFileUploadService.getUploadedBytes(String uploadUrl).

Actual Behaviour

I am uploading using this code in my controller:

@RequestMapping(value = "/api/upload")
//access Cross
@CrossOrigin(origins = "*")
public class TusController {
    @Autowired
    private TusFileUploadService tusFileUploadService;

    @Autowired
    HelperService helperService;

    @RequestMapping(value = {"", "/**"}, method = {RequestMethod.POST, RequestMethod.PATCH, RequestMethod.HEAD,
        RequestMethod.DELETE, RequestMethod.OPTIONS, RequestMethod.GET})
    public void processUpload(final HttpServletRequest servletRequest, final HttpServletResponse servletResponse) throws IOException, TusException, InterruptedException {
        tusFileUploadService.process(servletRequest, servletResponse);
        //access response header Location,Upload-Offset,Upload-length
        servletResponse.addHeader("Access-Control-Expose-Headers","Location,Upload-Offset,Upload-Length");
    }

        @RequestMapping(method = RequestMethod.GET, value = "/getBytesTus")
    public String getUploadedBytes() throws TusException, IOException {
                System.out.println(tusFileUploadService.getUploadedBytes("/api/upload"));
        return "done";
    }
}

Here the upload url is "/api/upload" and when I try to get the uploaded bytes using the getUploadedBytes() api which uses the getUploadedBytes with the upload URI I get this error: Method threw 'me.desair.tus.server.exception.UploadNotFoundException' exception.