Index: modules/dnet-s3-objectStore/trunk/src/main/java/eu/dnetlib/data/objectstore/s3/S3ObjectStore.java
===================================================================
--- modules/dnet-s3-objectStore/trunk/src/main/java/eu/dnetlib/data/objectstore/s3/S3ObjectStore.java	(revision 56854)
+++ modules/dnet-s3-objectStore/trunk/src/main/java/eu/dnetlib/data/objectstore/s3/S3ObjectStore.java	(revision 56855)
@@ -21,19 +21,19 @@
 import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
 import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
 import eu.dnetlib.enabling.resultset.ResultSetListener;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.tuple.ImmutableTriple;
-import org.apache.commons.lang3.tuple.Triple;
+import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.bson.Document;
-import org.apache.commons.lang3.exception.ExceptionUtils;
 
-
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
+import java.util.UUID;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Pattern;
 
@@ -58,14 +58,16 @@
     private final String s3EndPoint;
     private final String objectStoreBucket;
 
+    private final String basePath;
 
+
     private final MongoCollection<Document> mongoCollection;
 
-    private AmazonS3 client;
+//    private AmazonS3 client;
 
     private static final Log log = LogFactory.getLog(S3ObjectStore.class);
 
-    public S3ObjectStore(final String identifier, final String interpretation, final String s3AccessKey, final String s3SecretKey, final String s3EndPoint, final String objectStoreBucket, final MongoCollection<Document> mongoCollection) throws ObjectStoreServiceException {
+    public S3ObjectStore(final String identifier, final String interpretation, final String s3AccessKey, final String s3SecretKey, final String s3EndPoint, final String objectStoreBucket, final MongoCollection<Document> mongoCollection, final String basePath) throws ObjectStoreServiceException {
         this.id = identifier;
         this.interpretation = interpretation;
         this.s3AccessKey = s3AccessKey;
@@ -73,6 +75,7 @@
         this.mongoCollection = mongoCollection;
         this.s3EndPoint = s3EndPoint;
         this.objectStoreBucket = objectStoreBucket;
+        this.basePath = basePath;
     }
 
 
@@ -140,16 +143,20 @@
 
     @Override
     public String feedObjectRecord(ObjectStoreRecord objectStoreRecord) throws ObjectStoreServiceException {
-        if (client == null)
-            this.client = initializeClient();
+        final AmazonS3 client = initializeClient();
         try {
             long start = System.currentTimeMillis();
-            if (objectStoreRecord!= null && objectStoreRecord.getInputStream()!= null ) {
+            final Path result = saveAndGenerateMD5(objectStoreRecord.getInputStream(), basePath);
+            log.debug("Total time to download into fileSystem " + (System.currentTimeMillis() - start));
+            if (result!= null) {
                 log.debug("Saving object with ID: " + objectStoreRecord.getFileMetadata().getObjectID() + " on s3 ");
-                this.client.putObject(objectStoreBucket, id + "/" + objectStoreRecord.getFileMetadata().getObjectID(), objectStoreRecord.getInputStream(), null);
-                final S3Object s3Object = this.client.getObject(objectStoreBucket ,id+ "/" + objectStoreRecord.getFileMetadata().getObjectID());
+                client.putObject(objectStoreBucket, id + "/" + objectStoreRecord.getFileMetadata().getObjectID(), result.toFile());
                 log.debug("Total time to put into the ObjectStore " + (System.currentTimeMillis() - start));
+                log.debug("Deleting file");
+                boolean deleteSuccess = Files.deleteIfExists(result);
+                log.debug("Temporary file deleting success " + deleteSuccess);
                 log.debug("Saved object on s3 ");
+                final S3Object s3Object = client.getObject(objectStoreBucket ,id+ "/" + objectStoreRecord.getFileMetadata().getObjectID());
                 double timestamp = System.currentTimeMillis();
                 Document metadata = new Document()
                         .append(ID_FIELD, objectStoreRecord.getFileMetadata().getObjectID())
@@ -169,7 +176,6 @@
             log.error("Error on put file in the objectStore", e);
             log.error(ExceptionUtils.getStackTrace(e));
             throw new ObjectStoreServiceException(e);
-
         }
         return null;
     }
@@ -212,10 +218,9 @@
         if (response == null)
             throw new ObjectStoreServiceException("Error document not found with objectId: "+objectId);
 
-        if (this.client == null)
-            this.client = initializeClient();
+        final AmazonS3 client = initializeClient();
 
-        this.client.deleteObject(this.objectStoreBucket, String.format("%s/%s", this.id, response.get(ID_FIELD)));
+        client.deleteObject(this.objectStoreBucket, String.format("%s/%s", this.id, response.get(ID_FIELD)));
     }
 
     @Override
@@ -234,17 +239,15 @@
 
     @Override
     public boolean dropContent() throws ObjectStoreServiceException {
-        if (this.client == null) {
-            this.client = initializeClient();
-        }
+        final AmazonS3 client = initializeClient();
         final ListObjectsV2Request req = new ListObjectsV2Request().withBucketName(objectStoreBucket).withPrefix(id);
         ListObjectsV2Result result;
         do {
-            result = this.client.listObjectsV2(req);
+            result = client.listObjectsV2(req);
 
             for (S3ObjectSummary objectSummary : result.getObjectSummaries()) {
                 log.debug(String.format(" - %s (size: %d)\n", objectSummary.getKey(), objectSummary.getSize()));
-                this.client.deleteObject(objectStoreBucket, objectSummary.getKey());
+                client.deleteObject(objectStoreBucket, objectSummary.getKey());
                 log.debug("Object Deleted");
             }
             String token = result.getNextContinuationToken();
@@ -255,4 +258,17 @@
         this.mongoCollection.drop();
         return true;
     }
+
+    private static Path saveAndGenerateMD5(final InputStream inputStream, final String basePath) throws IOException {
+        if (inputStream == null) return null;
+        Path tempFile = Paths.get(basePath,  UUID.randomUUID().toString());
+        log.debug("Temp file On Default Location: " + tempFile.toString());
+        long size = 0;
+        try {
+            Files.copy(inputStream, tempFile, StandardCopyOption.REPLACE_EXISTING);
+        } catch (IOException e1) {
+            log.error(e1);
+        }
+        return tempFile;
+    }
 }
Index: modules/dnet-s3-objectStore/trunk/src/main/java/eu/dnetlib/data/objectstore/s3/S3ObjectStoreDao.java
===================================================================
--- modules/dnet-s3-objectStore/trunk/src/main/java/eu/dnetlib/data/objectstore/s3/S3ObjectStoreDao.java	(revision 56854)
+++ modules/dnet-s3-objectStore/trunk/src/main/java/eu/dnetlib/data/objectstore/s3/S3ObjectStoreDao.java	(revision 56855)
@@ -49,7 +49,10 @@
     @Value("${dnet.objectStore.s3.objectStoreBucket}")
     private String objectStoreBucket;
 
+    @Value("${dnet.objectStore.s3.basePath}")
+    private String objectStoreBasePath;
 
+
 	private Document getObjectStoreMetadata(final String objectStoreId) {
         String find_id = objectStoreId;
         if (objectStoreId.length() == 36) {
@@ -70,7 +73,7 @@
         if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+objectStoreId+" was not found");
         final MongoCollection<Document> collection = getDb().getCollection(objectStoreId.substring(0,36));
         collection.createIndexes(metadataIndexes);
-        return new S3ObjectStore(resultQuery.getString(OBJECTSTORE_ID_FIELD),resultQuery.getString(INTERPRETATION_FIELD),accessKey, secretKey, s3EndPoint, objectStoreBucket, collection);
+        return new S3ObjectStore(resultQuery.getString(OBJECTSTORE_ID_FIELD),resultQuery.getString(INTERPRETATION_FIELD),accessKey, secretKey, s3EndPoint, objectStoreBucket, collection, objectStoreBasePath);
     }
 
     @Override
Index: modules/dnet-s3-objectStore/trunk/src/main/resources/eu/dnetlib/data/objectsore/s3/applicationContext-s3-objectstore.properties
===================================================================
--- modules/dnet-s3-objectStore/trunk/src/main/resources/eu/dnetlib/data/objectsore/s3/applicationContext-s3-objectstore.properties	(revision 56854)
+++ modules/dnet-s3-objectStore/trunk/src/main/resources/eu/dnetlib/data/objectsore/s3/applicationContext-s3-objectstore.properties	(revision 56855)
@@ -1,4 +1,5 @@
 services.objectStore.mongodb.host=localhost
 services.objectStore.mongodb.port=27017
 services.objectStore.mongodb.db=objectStore
-services.objectStore.mongodb.connectionsPerHost=20
\ No newline at end of file
+services.objectStore.mongodb.connectionsPerHost=20
+dnet.objectStore.s3.basePath=/tmp
\ No newline at end of file
Index: modules/dnet-s3-objectStore/trunk/pom.xml
===================================================================
--- modules/dnet-s3-objectStore/trunk/pom.xml	(revision 56854)
+++ modules/dnet-s3-objectStore/trunk/pom.xml	(revision 56855)
@@ -14,10 +14,11 @@
     <dependencies>
         <dependency>
             <groupId>com.amazonaws</groupId>
-            <artifactId>aws-java-sdk</artifactId>
-            <version>1.11.478</version>
+            <artifactId>aws-java-sdk-s3</artifactId>
+            <version>1.11.592</version>
         </dependency>
 
+
         <dependency>
             <groupId>eu.dnetlib</groupId>
             <artifactId>dnet-modular-objectstore-service</artifactId>
