解决方法
我或多或少地从一些预生产代码中复制了这个:
OkHttpClient.Builder builder = new OkHttpClient.Builder().proxy(proxy).writeTimeout(10,TimeUnit.MINUTES); this.client = builder.build(); // ... Request.Builder requestBuilder = new Request.Builder().url(uploadUrl); for (TagEntry entry : item.getUploadUrlHeaders()) { requestBuilder.addHeader(entry.getKey(),entry.getValue()); } RequestBody requestBody = RequestBody.create(BINARY_MEDIA_TYPE,file.toFile()); requestBuilder.put(requestBody); final Response response = client.newCall(requestBuilder.build()).execute(); assert response.isSuccessful();