Skip to content

Commit 33db886

Browse files
authored
Added method to get object tags - following same layout as other methods
1 parent 7bfa6fc commit 33db886

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

services/s3.cfc

+22
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,28 @@ component {
225225
if ( len( arguments.VersionId ) ) queryParams[ 'versionId' ] = arguments.VersionId;
226226
return apiCall( region, 'GET', '/' & Bucket & '/' & ObjectKey, queryParams );
227227
}
228+
229+
/**
230+
* Retrieve an Object's tags from Amazon S3.
231+
* https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGETtagging.html
232+
* @Bucket the name of the bucket containing the object
233+
* @ObjectKey the object to get
234+
* @VersionId the specific version of an object to get (if versioning is enabled)
235+
*/
236+
public any function getObjectTagging(
237+
required string Bucket,
238+
required string ObjectKey,
239+
string VersionId = ''
240+
) {
241+
if ( !structKeyExists( arguments, 'Region' ) ) arguments.Region = variables.defaultRegion;
242+
var queryParams = {'tagging': '' };
243+
if ( len( arguments.VersionId ) ) queryParams[ 'versionId' ] = arguments.VersionId;
244+
var apiResponse = apiCall( region, 'GET', '/' & Bucket & '/' & ObjectKey, queryParams );
245+
if ( apiResponse.statusCode == 200 ) {
246+
apiResponse[ 'data' ] = utils.parseXmlResponse( apiResponse.rawData, 'TagSet' );
247+
}
248+
return apiResponse;
249+
}
228250

229251
/**
230252
* Retrieves metadata from an object without returning the object itself.

0 commit comments

Comments
 (0)