Class CloudPageMediaClient

java.lang.Object
vaultWeb.services.CloudPageMediaClient

@Service public class CloudPageMediaClient extends Object
Streams file bytes out of the cloud-page service on behalf of a user.

The request is forwarded rather than proxied blindly: this client mints a short-lived cloud-page access token for the named user, so cloud-page performs its own ownership and path-traversal checks exactly as it would for a direct call. The proxy therefore never widens what a user can reach.

Responses are returned as a live InputStream. Nothing is buffered into memory, which is the whole point of the exercise: a multi-gigabyte video must not be materialised on the vault-web heap in order to serve a 500 KB range request.

  • Constructor Details

    • CloudPageMediaClient

      public CloudPageMediaClient(@Value("${jwt.secret}") String sharedSecret, @Value("${app.cloudpage.base-url}") String cloudPageBaseUrl, @Value("${app.cloudpage.trust-self-signed:false}") boolean trustSelfSigned)
  • Method Details

    • fetch

      public HttpResponse<InputStream> fetch(String username, String path, String rangeHeader, String ifNoneMatch, String ifModifiedSince) throws IOException, InterruptedException
      Forwards a view request for a single file to cloud-page.
      Parameters:
      username - the user whose storage the file is read from
      path - the user-root-relative file path
      rangeHeader - the inbound Range header, or null if absent
      ifNoneMatch - the inbound If-None-Match header, or null
      ifModifiedSince - the inbound If-Modified-Since header, or null
      Returns:
      the upstream response, its body still streaming
      Throws:
      IOException
      InterruptedException