Browse Source

used amazon s3 client builder

master
Sebastian Rieger 7 years ago
parent
commit
dd6b0a26c4
  1. 7
      VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTService.java

7
VerteilteSysteme-Examples/src/verteiltesysteme/aws/TCPTimeCounterRESTService.java

@ -4,7 +4,6 @@ package verteiltesysteme.aws;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder; import com.amazonaws.services.s3.AmazonS3ClientBuilder;
@ -17,15 +16,13 @@ public class TCPTimeCounterRESTService {
private Long getCounter() { private Long getCounter() {
// Verbindung zu S3 // Verbindung zu S3
AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient();
s3Client.setRegion(com.amazonaws.regions.Region.getRegion(Regions.EU_CENTRAL_1));
AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withRegion(bucketRegion).build();
return new Long(s3Client.getObjectAsString(bucketName, bucketRegion)); return new Long(s3Client.getObjectAsString(bucketName, bucketRegion));
} }
private boolean setCounter(Long counter) { private boolean setCounter(Long counter) {
// Verbindung zu S3 // Verbindung zu S3
AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient();
s3Client.setRegion(com.amazonaws.regions.Region.getRegion(Regions.EU_CENTRAL_1));
AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withRegion(bucketRegion).build();
s3Client.putObject(bucketName, bucketRegion, new Long(counter).toString()); s3Client.putObject(bucketName, bucketRegion, new Long(counter).toString());
return true; return true;
} }

Loading…
Cancel
Save