aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Spurrier <matthew@spurrier.com.au>2015-01-29 18:19:58 +0800
committerShawn Pearce <spearce@spearce.org>2015-03-10 16:11:48 -0700
commit1383bdd5bca8b81394b12b5a9bd4d96c0be1f649 (patch)
tree9d1636037b86bd8aed4f6c55da7cb1a4b59dcbc8
parent1e694f3847e1f379a1c7998ef3b0c890fb04a854 (diff)
downloadjgit-1383bdd5bca8b81394b12b5a9bd4d96c0be1f649.tar.gz
jgit-1383bdd5bca8b81394b12b5a9bd4d96c0be1f649.zip
Make s3 domain dynamic to support different s3 regions
Change-Id: If8f9e85368c56d88bb6ae9efe1b3a29cc18cc1d5 Signed-off-by: Matthew Spurrier <matthew@spurrier.com.au>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
index 722bfc489d..705a84613c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
@@ -115,8 +115,6 @@ public class AmazonS3 {
private static final String HMAC = "HmacSHA1"; //$NON-NLS-1$
- private static final String DOMAIN = "s3.amazonaws.com"; //$NON-NLS-1$
-
private static final String X_AMZ_ACL = "x-amz-acl"; //$NON-NLS-1$
private static final String X_AMZ_META = "x-amz-meta-"; //$NON-NLS-1$
@@ -185,6 +183,9 @@ public class AmazonS3 {
/** Directory for locally buffered content. */
private final File tmpDir;
+ /** S3 Bucket Domain. */
+ private final String domain;
+
/**
* Create a new S3 client for the supplied user information.
* <p>
@@ -201,6 +202,10 @@ public class AmazonS3 {
* # PRIVATE, PUBLIC_READ (defaults to PRIVATE).
* acl: PRIVATE
*
+ * # S3 Domain
+ * # AWS S3 Region Domain (defaults to s3.amazonaws.com)
+ * domain: s3.amazonaws.com
+ *
* # Number of times to retry after internal error from S3.
* httpclient.retry-max: 3
*
@@ -214,6 +219,7 @@ public class AmazonS3 {
*
*/
public AmazonS3(final Properties props) {
+ domain = props.getProperty("domain", "s3.amazonaws.com"); //$NON-NLS-1$ //$NON-NLS-2$
publicKey = props.getProperty("accesskey"); //$NON-NLS-1$
if (publicKey == null)
throw new IllegalArgumentException(JGitText.get().missingAccesskey);
@@ -558,7 +564,7 @@ public class AmazonS3 {
urlstr.append("http://"); //$NON-NLS-1$
urlstr.append(bucket);
urlstr.append('.');
- urlstr.append(DOMAIN);
+ urlstr.append(domain);
urlstr.append('/');
if (key.length() > 0)
HttpSupport.encode(urlstr, key);
@@ -619,7 +625,7 @@ public class AmazonS3 {
final String host = c.getURL().getHost();
s.append('/');
- s.append(host.substring(0, host.length() - DOMAIN.length() - 1));
+ s.append(host.substring(0, host.length() - domain.length() - 1));
s.append(c.getURL().getPath());
final String sec;