Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make owner optional when fetching attributes #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/main/java/com/upplication/s3fs/util/S3Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ public S3ObjectSummary getS3ObjectSummary(S3Path s3Path) throws NoSuchFileExcept
result.setKey(key);
result.setLastModified(metadata.getLastModified());
result.setSize(metadata.getContentLength());
AccessControlList objectAcl = client.getObjectAcl(bucketName, key);
result.setOwner(objectAcl.getOwner());
try {
AccessControlList objectAcl = client.getObjectAcl(bucketName, key);
result.setOwner(objectAcl.getOwner());
} catch (AmazonS3Exception e) {
// If we don't have permission to view the ACL, that's fine, we can leave `owner` empty
if (e.getStatusCode() != 403)
throw e;
}
return result;
} catch (AmazonS3Exception e) {
if (e.getStatusCode() != 404)
Expand Down Expand Up @@ -189,4 +195,4 @@ public S3BasicFileAttributes toS3FileAttributes(S3ObjectSummary objectSummary, S
}
return new S3BasicFileAttributes(resolvedKey, lastModifiedTime, size, directory, regularFile);
}
}
}