diff --git a/src/main/java/org/gcube/contentmanagement/blobstorage/transport/plugin/S3PluginManager.java b/src/main/java/org/gcube/contentmanagement/blobstorage/transport/plugin/S3PluginManager.java index 74a504d..30f72cc 100644 --- a/src/main/java/org/gcube/contentmanagement/blobstorage/transport/plugin/S3PluginManager.java +++ b/src/main/java/org/gcube/contentmanagement/blobstorage/transport/plugin/S3PluginManager.java @@ -42,13 +42,14 @@ public class S3PluginManager extends TransportManager { S3Client s3; private Logger logger = LoggerFactory.getLogger(S3PluginManager.class); - -// THE FOLLOWING FIELDS SHOULD BE RETRIEVED FROM SERVICEENDPOINT - static final String ACCESS_KEY="UXMKEBMZBDROS5K9HREG"; - static final String SECRET_ACCESS_KEY="0Mqu8gmzcZ09wuqqKZwNmuS5bYC549MlZhvfgv6W"; - Region region = Region.EU_NORTH_1; -// final String END_POINT = "https://s3.wasabisys.com"; - static String bucket="g3-test1data"; // gcube-test;//"gcube-home-test-access"; +// +//// THE FOLLOWING FIELDS SHOULD BE RETRIEVED FROM SERVICEENDPOINT +// static final String ACCESS_KEY="UXMKEBMZBDROS5K9HREG"; +// static final String SECRET_ACCESS_KEY="0Mqu8gmzcZ09wuqqKZwNmuS5bYC549MlZhvfgv6W"; +// Region region = Region.EU_NORTH_1; +//// final String END_POINT = "https://s3.wasabisys.com"; +// static String bucket="g3-test1data"; // gcube-test;//"gcube-home-test-access"; + private Region region; private String token; @@ -82,33 +83,7 @@ public class S3PluginManager extends TransportManager { StaticCredentialsProvider.create(awsCreds)) .endpointOverride(URI.create(server[0])).region(this.region).build(); } - - -//// @Override -// public void initBackendzad(String[] server, String accessKey, String secretAccessKey, MemoryType memoryType, String[] dbNames, -// String writeConcern, String readConcern) { -//// region = Region.of("IT"); -// region = Region.of(dbNames[0]); -// String hardcodedToken="gAAAAABf3MQXCVgepxjLLPAaPb063qABbuMVERNoW7CrQgQpu-Phea-YG1aQEhBwbnQZqkAZMUfI3DaMbFdCPZ7sTJn2RY3hwP8y1qBQmt5oRTxJAHO01JdLcTAOtBLH7et1KPdo-AOLvuwWclYYI2nvztqeT2FhNK5irTY004tm_1pgwvuHRfE"; -//// AwsSessionCredentials awsCreds = AwsSessionCredentials.create(accessKey, secretAccessKey, ""); -// AwsSessionCredentials awsCreds = AwsSessionCredentials.create("1168063577b54b30bd35e9ed209e698e", "e60be85b39dc4e1e816f6d922c1f2c3a", token); -//// s3 = S3Client.builder().region(newRegion) -//// .credentialsProvider(StaticCredentialsProvider.create(awsCreds)) -//// .httpClientBuilder(ApacheHttpClient.builder().connectionTimeout(Duration.ofSeconds(30)) -//// .connectionMaxIdleTime(Duration.ofSeconds(30)).socketTimeout(Duration.ofSeconds(60))); -//// s3 = s3.endpointOverride(new URI("http://xxxxxxx")); -// -// -// -// s3 = S3Client.builder().credentialsProvider( -// StaticCredentialsProvider.create(awsCreds)) -// .endpointOverride(URI.create("https://vsa-0000000e-it-momit-01.zadarazios.com:443")).region(region).build(); -// -// -// -// } - - + @Override public Object get(Download download) throws FileNotFoundException, IOException { @@ -123,7 +98,6 @@ public class S3PluginManager extends TransportManager { if (!BucketOperator.isBucket(s3, bucketName)) BucketOperator.createBucketWaiter(s3, bucketName, region); File file= new File(upload.getResource().getLocalPath()); -// return BucketOperator.getInstance(s3).putObject(bucket, Utils.convertToS3Format(upload.getResource().getRemotePath()), file).toString(); int hashcode=BucketOperator.getInstance(s3).putObject(bucketName, Utils.convertToS3Format(upload.getResource().getRemotePath()), file, upload.isReplaceOption()).hashCode(); return hashcode+""; }