Skip to content

Commit

Permalink
fixing a logical issue with get on s3filestore
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryGeorgist committed Jun 17, 2024
1 parent 3829ff1 commit 16cd96b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ publishing {
}

group 'mil.army.usace.hec'
version '0.0.55'
version '0.0.56'
}
36 changes: 9 additions & 27 deletions src/main/java/usace/cc/plugin/FileDataStoreS3.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,18 @@ public Boolean Copy(FileDataStore destStore, String srcPath, String destPath) {
}
@Override
public InputStream Get(String path) {
//byte[] data;
S3Object fullObject = null;
String key = postFix + "/" + path;
System.out.println(path);
System.out.println(bucket);
try {
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) {
fullObject = awsS3.getObject(new GetObjectRequest(bucket, key));
System.out.println("Content-Type: " + fullObject.getObjectMetadata().getContentType());
return fullObject.getObjectContent();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

@Override
Expand Down

0 comments on commit 16cd96b

Please sign in to comment.