s3 impl
This commit is contained in:
34
src/s3/get-bucket-acl.handler.ts
Normal file
34
src/s3/get-bucket-acl.handler.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import * as Joi from 'joi';
|
||||
import { AbstractActionHandler, Format } from '../abstract-action.handler';
|
||||
import { Action } from '../action.enum';
|
||||
import { RequestContext } from '../_context/request.context';
|
||||
import { S3Service } from './s3.service';
|
||||
|
||||
type QueryParams = {
|
||||
Bucket: string;
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
export class GetBucketAclHandler extends AbstractActionHandler<QueryParams> {
|
||||
constructor(private readonly s3Service: S3Service) {
|
||||
super();
|
||||
}
|
||||
|
||||
format = Format.Xml;
|
||||
action = Action.S3GetBucketAcl;
|
||||
validator = Joi.object<QueryParams, true>({
|
||||
Bucket: Joi.string().required(),
|
||||
});
|
||||
|
||||
protected async handle({ Bucket }: QueryParams, { awsProperties }: RequestContext) {
|
||||
const acl = await this.s3Service.getBucketAcl(Bucket);
|
||||
|
||||
return {
|
||||
Owner: acl.Owner,
|
||||
AccessControlList: {
|
||||
Grant: acl.Grants.length > 0 ? acl.Grants : undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user