# Does TUSClient support Proxy

**URL:** <https://community.transloadit.com/t/does-tusclient-support-proxy/15983>\
**Category:** Tus\
**Created:** [March 4, 2022, 10:59am UTC](https://community.transloadit.com/t/does-tusclient-support-proxy/15983 "2022-03-04T10:59:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PratimSingha](https://avatars.discourse-cdn.com/v4/letter/p/ea5d25/32.png) [@PratimSingha](https://community.transloadit.com/u/PratimSingha)\
**Post date:** [March 4, 2022, 10:59am UTC](https://community.transloadit.com/t/does-tusclient-support-proxy/15983/1 "2022-03-04T10:59:43Z")

</div>

I am using TUSClient to upload large files in chunks to the server.  
Here is my code:

```auto
public void uploadFile(UploadFileResponse uploadFileResponse, File file) {

		try {
			if (System.getProperty("sun.net.http.allowRestrictedHeaders") == null) {
				System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
			}
			byte[] bytes = Files.readAllBytes(file.toPath());

			Map headers = new HashMap();
			headers.put("token", getToken());
			headers.put("Content-Length", Integer.toString(bytes.length));

			final TusUpload upload = new TusUpload(file);
			TusClient client = new TusClient();
			client.setUploadCreationURL(new URL(uploadFileResponse.getUploadUrl()));
			client.setHeaders(headers);
			client.enableResuming(new TusURLMemoryStore());

			Integer chunkSize = 1024 * 1024 * 1;

			Map metadata = new HashMap();
			metadata.put("name", file.getName());
			metadata.put("chunkSize", String.format("%d", chunkSize));
			metadata.put("contentType", "text/xml");
			upload.setMetadata(metadata);
			
			TusExecutor executor = new TusExecutor() {
				@Override
				protected void makeAttempt() throws IOException, ProtocolException {

					TusUploader uploader = client.resumeOrCreateUpload(upload);
					uploader.setChunkSize(chunkSize);
					int result = 0;
					do {
						result = uploader.uploadChunk();
					} while (result > -1);

					uploader.finish();
				}
			};
			executor.makeAttempts();
		}catch (Exception e){
			throw new customException(e);
		}
	}

```

Please consider the server has a Proxy URL to connect to outer world.  
`uploadFileResponse.getUploadUrl()`  
Please consider the above statement will return the outer world URL.  
How to add Proxy support here.

---

<div class="post-metadata">

**Author:** ![marius](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.transloadit.com/marius/32/572_2.png) [@marius](https://community.transloadit.com/u/marius)\
**Post date:** [March 17, 2022, 3:11pm UTC](https://community.transloadit.com/t/does-tusclient-support-proxy/15983/2 "2022-03-17T15:11:35Z")

</div>

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: [How to use HttpsURLConnection through proxy by setProperty? URL connection and proxy : HttpURLConnection – Java in&Out Blog](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: [tus-java-client/TusClient.java at master · tus/tus-java-client · GitHub](https://github.com/tus/tus-java-client/blob/master/src/main/java/io/tus/java/client/TusClient.java#L319)

Hope that helps!
