Reputation: 411
I'm trying to get all objects including different versions of the same object as well. According to aws official documents, it has Prefix
and KeyMarker
. I can't see any special difference between them. It says both like below,
I'd like you to take an example to get to know it if possible. Thanks.
FYI) I took an example like my bucket name is example
and my file is located in app/a.json
in the bucket. In that case, it can call listObjectVersions
with the param: { Bucket: "example", "Prefix": "app/a.json" }
but doesn't work with { Bucket: "example", "KeyMarker": "app/a.json" }
Upvotes: 1
Views: 638
Reputation: 35188
There is a pretty big difference between the both of these, although I can see how it can be easy to get confused with the terminology.
Prefix
This is used for requests to limit objects based on a start pattern, all S3 "filepaths" are actually the entire key.
So if you wanted to retrieve everything that on a file based system exists in the docs
folder in the root of the system, in S3 you would reference the prefix of docs/*
to get all objects with a key starting with docs/
.
KeyMarker
This can be used in conjunction or independently to prefix, it comes down to when your list objects request returns too many objects to list, it becomes paginated returning you both the objects and a property named NextKeyMarker
.
You would use this property to perform the same request again but this time adding the value of the NextKeyMarker
as your KeyMarker
. This would essentially return you the next page starting with the key you have specified.
Upvotes: 3