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

A base URI other than '/upload' causes a null pointer exception when calling getUploadInfo #28

Closed uvinw closed 4 years ago

uvinw commented 4 years ago

Expected Behaviour

Ability to handle a TUS apload regardless of what the base URI is. For instance /api/upload causes this error but /upload works fine.

Actual Behaviour

UploadInfo is not captured from the request. Any attempts at using the TusFileUploadService to fetch (getUploadInfo) results in a null pointer exception.

Steps to reproduce

Create a basic implementation using a base URI other than simple 'upload'. For example (in Spring):

@RequestMapping(value = { "/api/upload", "/api/upload/**" }, method = { RequestMethod.POST,
      RequestMethod.PATCH, RequestMethod.HEAD, RequestMethod.DELETE, RequestMethod.GET })
  public void upload(HttpServletRequest servletRequest,
      HttpServletResponse servletResponse) throws IOException {
    this.tusFileUploadService.process(servletRequest, servletResponse);

    String uploadURI = servletRequest.getRequestURI();

    UploadInfo uploadInfo = null;
    try {
      uploadInfo = this.tusFileUploadService.getUploadInfo(uploadURI);
      //this is null
    }
    catch (IOException | TusException e) {
      Application.logger.error("get upload info", e);
    }
}
lawrence1999 commented 11 months ago

How did you solve it?