DImuthuUpe commented on a change in pull request #1: NIO based file transport 
implementation
URL: https://github.com/apache/airavata-mft/pull/1#discussion_r314576866
 
 

 ##########
 File path: 
transport/s3-transport/src/main/java/org/apache/airavata/mft/transport/s3/S3SinkConnector.java
 ##########
 @@ -0,0 +1,93 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ */
+
+package org.apache.airavata.mft.transport.s3;
+
+import com.amazonaws.HttpMethod;
+import com.amazonaws.services.s3.AmazonS3;
+import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
+import org.apache.airavata.mft.core.api.ConnectorChannel;
+import org.apache.airavata.mft.core.api.SinkConnector;
+import org.apache.airavata.mft.core.bufferedImpl.AbstractConnector;
+import org.apache.airavata.mft.core.bufferedImpl.ConnectorConfig;
+import org.apache.airavata.mft.core.bufferedImpl.Constants;
+import org.apache.airavata.mft.core.bufferedImpl.OutChannel;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.channels.Channel;
+import java.util.Properties;
+
+/**
+ * Connector class which connects to a given S3 destination and provides
+ * S3 output Stream.
+ */
+public class S3SinkConnector extends AbstractConnector implements 
SinkConnector {
+    private AmazonS3 s3Client;
+
+
+    @Override
+    public boolean initiate(ConnectorConfig connectorConfig) {
+        s3Client = 
S3TransportUtil.getS3Client(connectorConfig.getValue(S3Constants.ACCESS_KEY),
+                connectorConfig.getValue(S3Constants.SECRET_KEY), 
connectorConfig.getValue(S3Constants.REGION));
+        return true;
+    }
+
+    @Override
+    public ConnectorChannel openChannel(Properties properties) throws 
IOException {
+        java.util.Date expiration = new java.util.Date();
+        long expTimeMillis = expiration.getTime();
+        expTimeMillis += S3Constants.CONNECTION_EXPIRE_TIME;
+        expiration.setTime(expTimeMillis);
+
+        GeneratePresignedUrlRequest generatePresignedUrlRequest = new 
GeneratePresignedUrlRequest
 
 Review comment:
   Why can't we use s3client.putObject method instead of this approach?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to