tus / tus-java-client

The tus client for Java.
https://tus.io
MIT License
213 stars 88 forks source link

How to set Proxy for TUSClient? #52

Closed pratimsingha closed 1 year ago

pratimsingha commented 2 years ago

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 TUSClientclass, 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:

Acconut commented 2 years ago

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 commented 1 year ago

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

pdenooijer commented 1 year ago

@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.