// Groovy Version: 2.4.11 JVM: 1.8.0_144 Vendor: Oracle Corporation OS: Mac OS X
@Grab('com.amazonaws:aws-java-sdk-s3:1.11.184')
import com.amazonaws.regions.Regions
import com.amazonaws.services.s3.AmazonS3
import com.amazonaws.services.s3.AmazonS3ClientBuilder
AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
.withRegion(Regions.AP_NORTHEAST_1)
.build()
def bucketName = 'your-bucket-name'
def key = 'some/s3/key'
def s3metadata = s3Client.getObjectMetadata(bucketName, key)
s3metadata.properties.each { k, v ->
if(k in ["metaClass", "class"]) return
println "$k: $v"
}
結果
serverSideEncryption: null
ETag: bff9fd94c2d3d672213687840a21d3d4
instanceLength: 258770
userMetadata: [:]
contentDisposition: null
rawMetadata: [Accept-Ranges:bytes, Content-Length:258770, Content-Type:image/jpeg, ETag:bff9fd94c2d3d672213687840a21d3d4, Last-Modified:Fri Nov 10 18:18:39 JST 2017]
replicationStatus: null
contentRange: null
ongoingRestore: null
SSECustomerAlgorithm: null
requesterCharged: false
expirationTimeRuleId: null
storageClass: null
restoreExpirationTime: null
contentLength: 258770
lastModified: Fri Nov 10 18:18:39 JST 2017
versionId: null
cacheControl: null
SSECustomerKeyMd5: null
SSEAwsKmsKeyId: null
contentEncoding: null
SSEAlgorithm: null
contentType: image/jpeg
contentMD5: null
httpExpiresDate: null
contentLanguage: null
partCount: null
expirationTime: null