Skip to content
Permalink
Browse files

[JENKINS-51402] Presigned url has the wrong region

when running from a different one
  • Loading branch information
carlossg committed May 22, 2018
1 parent ea314b9 commit 83fa8293cbedf76accb9ae2142dec57e87bd9169
@@ -354,6 +354,8 @@ public Void invoke(File f, VirtualChannel channel) throws IOException, Interrupt
* Upload a file to a URL
*/
private static void uploadFile(Path f, URL url) throws IOException {
// AWS will redirect to the bucket region if different
HttpURLConnection.setFollowRedirects(true);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("PUT");
@@ -362,7 +364,7 @@ private static void uploadFile(Path f, URL url) throws IOException {
Files.copy(f, out);
}
int responseCode = connection.getResponseCode();
if (responseCode < 200 || responseCode >= 300) {
if (responseCode < 200 || responseCode >= 400) {
throw new IOException(String.format("Failed to upload %s to %s, response: %d %s", f.toAbsolutePath(), url,
responseCode, connection.getResponseMessage()));
}

0 comments on commit 83fa829

Please sign in to comment.
You can’t perform that action at this time.