AWS SDK for Goを使って、S3のバケット内の画像情報を取得してみる


svc := s3.New(session.New())

params := &s3.ListObjectsInput{
    Bucket:       aws.String("BucketName"), // Required
    Delimiter:    aws.String("Delimiter"),
    EncodingType: aws.String("EncodingType"),
    Marker:       aws.String("Marker"),
    MaxKeys:      aws.Int64(1),
    Prefix:       aws.String("Prefix"),
resp, err := svc.ListObjects(params)

if err != nil {
    // Print the error, cast err to awserr.Error to get the Code and
    // Message from an error.

// Pretty-print the response data.


  • Bucket(*string)
  • Marker(*string)
Specifies the key to start with when listing objects in a bucket.
  • EncodingType(*string enum)
Requests Amazon S3 to encode the object keys in the response and specifies the encoding method to use.  
An object key may contain any Unicode character;  
however, XML 1.0 parser cannot parse some characters, such as characters with an ASCII value from 0 to 10.  
For characters that are not supported in XML 1.0,
you can add this parameter to request that Amazon S3 encode the keys in the response.

Enum Values:
s3.EncodingTypeUrl = "url"
  • Delimiter(*string)
A delimiter is a character you use to group keys.


  • MaxKeys(*int64)
Sets the maximum number of keys returned in the response. 
The response might contain fewer keys but will never contain more.


  • Prefix(*string)
Limits the response to keys that begin with the specified prefix.