mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-09-30 14:43:13 +00:00
Complete API layer with Clean Architecture: - Application DTOs (proposals, line items, customers, users, files, audit, dashboard) - Service interfaces (IProposalService, ILineItemService, ICustomerService, IAuditService, IS3Service, IJobPublisher) - FluentValidation validators for all create requests - Infrastructure service implementations (ProposalService, LineItemService, CustomerService, AuditService, S3Service, SqsJobPublisher, ProposalNumberGenerator) - Secrets Manager connection string resolver for RDS - API controllers: Proposals (CRUD + approve/send/revise), LineItems (CRUD + bulk), Customers, Users, Files (presigned upload/download), Admin (dashboard) - Middleware: GlobalExceptionHandler (ProblemDetails), ValidationFilter (FluentValidation pipeline) - CurrentUserService (Cognito JWT claims -> User entity, auto-provisioning) - Full DI configuration in Program.cs with Lambda hosting - Role-based authorization (dispatchers, admins, sysadmins) - CORS configured for proposals.seahaven.com + localhost
44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using Amazon.S3;
|
|
using Amazon.S3.Model;
|
|
using ProposalSystem.Application.Interfaces;
|
|
|
|
namespace ProposalSystem.Infrastructure.Services;
|
|
|
|
public class S3Service : IS3Service
|
|
{
|
|
private readonly IAmazonS3 _s3Client;
|
|
|
|
public S3Service(IAmazonS3 s3Client)
|
|
{
|
|
_s3Client = s3Client;
|
|
}
|
|
|
|
public Task<string> GeneratePresignedUploadUrlAsync(string bucket, string key, string contentType, int expirationMinutes = 15)
|
|
{
|
|
var request = new GetPreSignedUrlRequest
|
|
{
|
|
BucketName = bucket,
|
|
Key = key,
|
|
Verb = HttpVerb.PUT,
|
|
Expires = DateTime.UtcNow.AddMinutes(expirationMinutes),
|
|
ContentType = contentType,
|
|
};
|
|
|
|
var url = _s3Client.GetPreSignedURL(request);
|
|
return Task.FromResult(url);
|
|
}
|
|
|
|
public Task<string> GeneratePresignedDownloadUrlAsync(string bucket, string key, int expirationMinutes = 60)
|
|
{
|
|
var request = new GetPreSignedUrlRequest
|
|
{
|
|
BucketName = bucket,
|
|
Key = key,
|
|
Verb = HttpVerb.GET,
|
|
Expires = DateTime.UtcNow.AddMinutes(expirationMinutes),
|
|
};
|
|
|
|
var url = _s3Client.GetPreSignedURL(request);
|
|
return Task.FromResult(url);
|
|
}
|
|
}
|