Skip to content

Commit

Permalink
Updated to correct folder structure #3921
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrys committed Jul 31, 2017
1 parent 3978029 commit ecf96ba
Showing 1 changed file with 15 additions and 35 deletions.
50 changes: 15 additions & 35 deletions src/main/java/edu/harvard/iq/dataverse/dataaccess/S3AccessIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,8 @@ public S3AccessIO(T dvObject, DataAccessRequest req) {
this.setIsLocalFile(false);
}

//FIXME: Delete vars?
private boolean isReadAccess = false;
private boolean isWriteAccess = false;
private AWSCredentials awsCredentials = null;
private AmazonS3 s3 = null;


//FIXME: Copied, change?
@Override
public boolean canRead() {
return isReadAccess;
}

//FIXME: Copied, change?
@Override
public boolean canWrite() {
return isWriteAccess;
}


// @Override
// public DvObjectType getDvObjectType() {
//
// }

//FIXME: Finish
@Override
Expand Down Expand Up @@ -133,13 +111,12 @@ public void open(DataAccessOption... options) throws IOException {
} catch (Exception ex) {
this.setFileName("unknown");
}




} else if (dvObject instanceof Dataset) {

} else if (dvObject instanceof Dataverse) {
Dataverse dataverse = this.getDataverse();

} else {
throw new IOException("Data Access: Invalid DvObject type");
}
Expand All @@ -159,16 +136,21 @@ public void savePath(Path fileSystemPath) throws IOException {

try {
File inputFile = fileSystemPath.toFile();
if (dvObject instanceof DataFile) {
DataFile datafile = (DataFile)dvObject;
String bucketName = "testiqss-1239759fgsef34w4"; //name is global, no uppercase

String bucketName = "testiqss-1239759fgsef34w4"; //name is global, no uppercase
s3.deleteBucket(bucketName);
String key = "MyObjectKey";
s3.deleteBucket(bucketName);
String key = datafile.getOwner().getAuthority() + "/" + datafile.getOwner().getIdentifier() + "/" + datafile.getDisplayName();

s3.createBucket(bucketName);
s3.putObject(new PutObjectRequest(bucketName, key, inputFile));

newFileSize = inputFile.length();
s3.createBucket(bucketName);
s3.putObject(new PutObjectRequest(bucketName, key, inputFile));

newFileSize = inputFile.length();
} else {
throw new IOException("DvObject type other than datafile is not yet supported");
}

} catch (SdkClientException ioex) {
String failureMsg = ioex.getMessage();
if (failureMsg == null) {
Expand All @@ -180,9 +162,7 @@ public void savePath(Path fileSystemPath) throws IOException {

// if it has uploaded successfully, we can reset the size
// of the object:

//FIXME: do this?
//setSize(newFileSize);
setSize(newFileSize);

}

Expand Down

0 comments on commit ecf96ba

Please sign in to comment.