diff --git a/source/java/src/org/lucee/extension/resource/ResourceSupport.java b/source/java/src/org/lucee/extension/resource/ResourceSupport.java index 6fc8444..e4208df 100755 --- a/source/java/src/org/lucee/extension/resource/ResourceSupport.java +++ b/source/java/src/org/lucee/extension/resource/ResourceSupport.java @@ -27,7 +27,6 @@ import lucee.commons.io.res.filter.ResourceFilter; import lucee.commons.io.res.filter.ResourceNameFilter; import lucee.loader.engine.CFMLEngine; -import lucee.loader.util.Util; /** * Helper class to build resources diff --git a/source/java/src/org/lucee/extension/resource/s3/AmazonS3Client.java b/source/java/src/org/lucee/extension/resource/s3/AmazonS3Client.java index 86b0ea8..372b46c 100644 --- a/source/java/src/org/lucee/extension/resource/s3/AmazonS3Client.java +++ b/source/java/src/org/lucee/extension/resource/s3/AmazonS3Client.java @@ -94,6 +94,18 @@ public AmazonS3 create() throws S3Exception { return builder.build(); } + public boolean isBackBlaze() { + return host != null && host.toLowerCase().indexOf(S3.BACKBLAZE.toLowerCase()) != -1; + } + + public boolean isWasabi() { + return host != null && host.toLowerCase().indexOf(S3.WASABI.toLowerCase()) != -1; + } + + public boolean isGoogle() { + return host != null && host.toLowerCase().indexOf(S3.GOOGLE.toLowerCase()) != -1; + } + private boolean isExpired() { return (liveTimeout + System.currentTimeMillis()) < created; } diff --git a/source/java/src/org/lucee/extension/resource/s3/S3.java b/source/java/src/org/lucee/extension/resource/s3/S3.java index 24b0d09..17385a0 100755 --- a/source/java/src/org/lucee/extension/resource/s3/S3.java +++ b/source/java/src/org/lucee/extension/resource/s3/S3.java @@ -91,8 +91,12 @@ public class S3 { public static final String DEFAULT_HOST = "s3.amazonaws.com"; public static final long DEFAULT_LIVE_TIMEOUT = 600000L; public static final String GOOGLE = ".googleapis.com"; + public static final String WASABI = ".wasabisys.com"; + public static final String AWS = ".amazonaws.com"; + public static final String BACKBLAZE = ".backblazeb2.com"; + public static final String DREAM_IO = ".dream.io"; - public static final String[] PROVIDERS = new String[] { ".amazonaws.com", ".wasabisys.com", ".backblazeb2.com", ".digitaloceanspaces.com", ".dream.io", GOOGLE }; + public static final String[] PROVIDERS = new String[] { AWS, WASABI, BACKBLAZE, ".digitaloceanspaces.com", DREAM_IO, GOOGLE }; private static final ConcurrentHashMap tokens = new ConcurrentHashMap(); private static final int CHECK_INTERVALL = 1000; @@ -2561,5 +2565,4 @@ public void shutdown() throws S3Exception { public long getLiveTimeout() { return liveTimeout; } - } \ No newline at end of file diff --git a/tests/tickets/LDEV4635.cfc b/tests/tickets/LDEV4635.cfc index 2ea5bcf..3225c4a 100644 --- a/tests/tickets/LDEV4635.cfc +++ b/tests/tickets/LDEV4635.cfc @@ -67,15 +67,15 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="s3" { // Blackbaze it(title="Copying dir to a new s3 bucket, valid region name [us-east-1]", skip=Util::isBackBlazeNotSupported(), body=function( currentSpec ) { - copyToBucket(getCredentials("BackBlaze"), "us-east-1", "us-east-1" ); + copyToBucket(getCredentials("BackBlaze"), "us-east-1", "" ); }); it(title="Copying dir to a new s3 bucket, valid region name [eu-west-1]", skip=Util::isBackBlazeNotSupported(), body=function( currentSpec ) { - copyToBucket(getCredentials("BackBlaze"), "eu-west-1", "eu-west-1" ); + copyToBucket(getCredentials("BackBlaze"), "eu-west-1", "" ); }); it(title="Copying dir to a new s3 bucket, valid region name [eu-west-1]", skip=Util::isBackBlazeNotSupported(), body=function( currentSpec ) { - copyToBucket(getCredentials("BackBlaze"), "eu-west-1", "eu-central-1" ); // fails, can't current copy between regions LDEV-4639 + copyToBucket(getCredentials("BackBlaze"), "eu-west-1", "" ); // fails, can't current copy between regions LDEV-4639 }); it(title="Copying dir to a new s3 bucket, invalid region name [down-under]", skip=Util::isBackBlazeNotSupported(), body=function( currentSpec ){ @@ -144,10 +144,12 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="s3" { } private function getCredentials(required string provider) localmode=true { - if("BackBlaze"==arguments.provider) return Util::getBackBlazeCredentials(); - else if("AWS"==arguments.provider) return Util::getAWSCredentials(); - else if("Wasabi"==arguments.provider) return Util::getWasabiCredentials(); - else if("Google"==arguments.provider) return Util::getGoogleCredentials(); + if("BackBlaze"==arguments.provider) local.credentials = Util::getBackBlazeCredentials(); + else if("AWS"==arguments.provider) local.credentials = Util::getAWSCredentials(); + else if("Wasabi"==arguments.provider) local.credentials = Util::getWasabiCredentials(); + else if("Google"==arguments.provider) local.credentials = Util::getGoogleCredentials(); + local.credentials.provider=arguments.provider; + return local.credentials; } }