s3_list_objects_v2: Returns some or all (up to 1,000) of the objects in a bucket

Description Usage Arguments Value Request syntax Examples

View source: R/s3_operations.R

Description

Returns some or all (up to 1,000) of the objects in a bucket. You can use the request parameters as selection criteria to return a subset of the objects in a bucket. A 200 OK response can contain valid or invalid XML. Make sure to design your application to parse the contents of the response and handle it appropriately.

To use this operation, you must have READ access to the bucket.

To use this operation in an AWS Identity and Access Management (IAM) policy, you must have permissions to perform the s3:ListBucket action. The bucket owner has this permission by default and can grant this permission to others. For more information about permissions, see Permissions Related to Bucket Subresource Operations and Managing Access Permissions to Your Amazon S3 Resources.

This section describes the latest revision of the API. We recommend that you use this revised API for application development. For backward compatibility, Amazon S3 continues to support the prior version of this API, list_objects.

To get a list of your buckets, see list_buckets.

The following operations are related to list_objects_v2:

Usage

1
2
3
s3_list_objects_v2(Bucket, Delimiter, EncodingType, MaxKeys, Prefix,
  ContinuationToken, FetchOwner, StartAfter, RequestPayer,
  ExpectedBucketOwner)

Arguments

Bucket

[required] Bucket name to list.

When using this API with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this operation with an access point through the AWS SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using Access Points in the Amazon Simple Storage Service Developer Guide.

When using this API with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When using this operation using S3 on Outposts through the AWS SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon Simple Storage Service Developer Guide.

Delimiter

A delimiter is a character you use to group keys.

EncodingType

Encoding type used by Amazon S3 to encode object keys in the response.

MaxKeys

Sets the maximum number of keys returned in the response. By default the API returns up to 1,000 key names. The response might contain fewer keys but will never contain more.

Prefix

Limits the response to keys that begin with the specified prefix.

ContinuationToken

ContinuationToken indicates Amazon S3 that the list is being continued on this bucket with a token. ContinuationToken is obfuscated and is not a real key.

FetchOwner

The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true.

StartAfter

StartAfter is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this specified key. StartAfter can be any key in the bucket.

RequestPayer

Confirms that the requester knows that she or he will be charged for the list objects request in V2 style. Bucket owners need not specify this parameter in their requests.

ExpectedBucketOwner

The account id of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error.

Value

A list with the following syntax:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
list(
  IsTruncated = TRUE|FALSE,
  Contents = list(
    list(
      Key = "string",
      LastModified = as.POSIXct(
        "2015-01-01"
      ),
      ETag = "string",
      Size = 123,
      StorageClass = "STANDARD"|"REDUCED_REDUNDANCY"|"GLACIER"|"STANDARD_IA"|"ONEZONE_IA"|"INTELLIGENT_TIERING"|"DEEP_ARCHIVE"|"OUTPOSTS",
      Owner = list(
        DisplayName = "string",
        ID = "string"
      )
    )
  ),
  Name = "string",
  Prefix = "string",
  Delimiter = "string",
  MaxKeys = 123,
  CommonPrefixes = list(
    list(
      Prefix = "string"
    )
  ),
  EncodingType = "url",
  KeyCount = 123,
  ContinuationToken = "string",
  NextContinuationToken = "string",
  StartAfter = "string"
)

Request syntax

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
svc$list_objects_v2(
  Bucket = "string",
  Delimiter = "string",
  EncodingType = "url",
  MaxKeys = 123,
  Prefix = "string",
  ContinuationToken = "string",
  FetchOwner = TRUE|FALSE,
  StartAfter = "string",
  RequestPayer = "requester",
  ExpectedBucketOwner = "string"
)

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
# The following example retrieves object list. The request specifies max
# keys to limit response to include only 2 object keys.
svc$list_objects_v2(
  Bucket = "examplebucket",
  MaxKeys = "2"
)

## End(Not run)

paws.storage documentation built on March 7, 2021, 5:07 p.m.