tus-java-client icon indicating copy to clipboard operation
tus-java-client copied to clipboard

How to set Proxy for TUSClient?

Open pratimsingha opened this issue 3 years ago • 1 comments

Question How to set Proxy for TUSClient?

We are using TUSClient to upload a large file to a server in chunks. We are required to go via Proxy server (with authentication). But when I see the createUpload method in TUSClient class, I see this below line: HttpURLConnection connection = (HttpURLConnection) uploadCreationURL.openConnection();

I could not see any Proxy feature that we can enable or introduce. Please suggest.

Setup details Please provide following details, if applicable to your situation:

  • Runtime environment: [Java Version 11]
  • Used tus-java-client version: [e.g. v0.4.3]

pratimsingha avatar Mar 14 '22 14:03 pratimsingha

tus-java-client does not have any feature for proxy support yet. If you want to contribute one, feel free to open a PR. As a workaround you can set a proxy for all HttpUrlConnections as described in this article: https://manismaran.wordpress.com/how-to-use-httpsurlconnection-through-proxy-by-setproperty-url-connection-and-proxy-httpurlconnection/ If you want to modify the HttpUrlConnection to add authentication (or similar), you can override the prepareConnection method in your own subclass of TusClient: https://github.com/tus/tus-java-client/blob/master/src/main/java/io/tus/java/client/TusClient.java#L319

Hope that helps!

Acconut avatar Mar 17 '22 15:03 Acconut

We will investigate into an easier way for setting proxies in the next major release: https://github.com/tus/tus-java-client/issues/78

Acconut avatar Jan 17 '23 12:01 Acconut

@Acconut as said by @LaravZ in https://github.com/tus/tus-java-client/issues/78#issuecomment-1456353698. We could fix this pretty quickly and robust. Would you be open to review the code (provided we create a PR), merge it (after comments are resolved) and create a new release? The lack of this feature is blocking our implementation. We're behind a proxy for external connections, but don't want to use it for all request as most of them are local.

pdenooijer avatar Mar 06 '23 15:03 pdenooijer