diff --git a/src/main/java/usace/cc/plugin/FileDataStoreS3.java b/src/main/java/usace/cc/plugin/FileDataStoreS3.java index eecfd02..4cab661 100644 --- a/src/main/java/usace/cc/plugin/FileDataStoreS3.java +++ b/src/main/java/usace/cc/plugin/FileDataStoreS3.java @@ -47,12 +47,33 @@ public Boolean Copy(FileDataStore destStore, String srcPath, String destPath) { } @Override public InputStream Get(String path) { - byte[] data; + //byte[] data; try { - data = GetObject(path); - ByteArrayInputStream bias = new ByteArrayInputStream(data); - return bias; - } catch (RemoteException e) { + S3Object fullObject = null; + String key = postFix + "/" + path; + System.out.println(path); + System.out.println(bucket); + try { + fullObject = awsS3.getObject(new GetObjectRequest(bucket, key)); + System.out.println("Content-Type: " + fullObject.getObjectMetadata().getContentType()); + return fullObject.getObjectContent(); + } catch (Exception e) { + throw e; + } finally { + // To ensure that the network connection doesn't remain open, close any open input streams. + if (fullObject != null) { + try { + fullObject.close(); + } catch (Exception e) { + System.out.println("key " + key + " failed to download.\n" + e.getMessage()); + throw e; + + //return fullObject.getObjectContent(); + } + } + } + + } catch (Exception e) { e.printStackTrace(); return null; }