Skip to content

Commit 1493039

Browse files
committed
[#2] Support AWS S3 (ACL is public)
1 parent f762ffd commit 1493039

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

thumbly-http-client/src/main/java/org/code13k/thumbly/web/client/aws/AwsS3SignerV4.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.code13k.thumbly.web.client.aws;
22

33
import io.vertx.core.MultiMap;
4+
import org.apache.commons.lang3.StringUtils;
45
import org.slf4j.Logger;
56
import org.slf4j.LoggerFactory;
67
import uk.co.lucasweb.aws.v4.signer.HttpRequest;
@@ -24,6 +25,14 @@ public class AwsS3SignerV4 {
2425
*/
2526
public static boolean putHeaders(MultiMap headers, String url, AwsS3SignValue awsS3SignValue) {
2627
try {
28+
// Check
29+
if(StringUtils.isEmpty(awsS3SignValue.getAccessKey())==true){
30+
return true;
31+
}
32+
if(StringUtils.isEmpty(awsS3SignValue.getSecretKey())==true){
33+
return false;
34+
}
35+
2736
// Init
2837
URI uri = new URI(url);
2938
HttpRequest request = new HttpRequest("GET", uri);

thumbly-main/src/main/java/org/code13k/thumbly/config/ChannelConfig.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,7 @@ else if (type.equalsIgnoreCase(ChannelType.AWS_S3)) {
127127
awsS3Info.setBucket(bucket);
128128

129129
// Check validation
130-
if (StringUtils.isEmpty(awsS3Info.getAccessKey()) == true) {
131-
mLogger.error("Invalid aws_s3 channel (access_key is invalid)");
132-
} else if (StringUtils.isEmpty(awsS3Info.getSecretKey()) == true) {
133-
mLogger.error("Invalid aws_s3 channel (secret_key is invalid)");
134-
} else if (StringUtils.isEmpty(awsS3Info.getRegion()) == true) {
130+
if (StringUtils.isEmpty(awsS3Info.getRegion()) == true) {
135131
mLogger.error("Invalid aws_s3 channel (region is invalid)");
136132
} else if (StringUtils.isEmpty(awsS3Info.getBucket()) == true) {
137133
mLogger.error("Invalid aws_s3 channel (bucket is invalid)");

thumbly-main/src/main/java/org/code13k/thumbly/model/config/channel/AwsS3Info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class AwsS3Info extends ChannelInfo {
88

99
@Override
1010
public String getBaseUrl() {
11-
return "https://s3." + region + ".amazonaws.com";
11+
return "https://s3." + region + ".amazonaws.com/" + bucket;
1212
}
1313

1414
public String getAccessKey() {

thumbly-main/src/main/java/org/code13k/thumbly/service/main/MainHttpServer.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,16 @@ private void handler(RoutingContext routingContext,
278278
AwsS3SignValue awsS3SignValue = null;
279279
if (channelInfo.getType() == ChannelConfig.ChannelType.AWS_S3) {
280280
AwsS3Info awsS3Info = (AwsS3Info) channelInfo;
281-
awsS3SignValue = new AwsS3SignValue();
282-
awsS3SignValue.setAccessKey(awsS3Info.getAccessKey());
283-
awsS3SignValue.setSecretKey(awsS3Info.getSecretKey());
284-
awsS3SignValue.setRegion(awsS3Info.getRegion());
281+
if (StringUtils.isEmpty(awsS3Info.getAccessKey()) == false) {
282+
if (StringUtils.isEmpty(awsS3Info.getSecretKey()) == false) {
283+
awsS3SignValue = new AwsS3SignValue();
284+
awsS3SignValue.setAccessKey(awsS3Info.getAccessKey());
285+
awsS3SignValue.setSecretKey(awsS3Info.getSecretKey());
286+
awsS3SignValue.setRegion(awsS3Info.getRegion());
287+
}
288+
}
285289
}
290+
mLogger.trace("awsS3SignValue = " + awsS3SignValue);
286291

287292
/**
288293
* Get origin file

0 commit comments

Comments
 (0)