Class ProfilePhotoController
- Namespace
- Builvero.Api.Controllers
- Assembly
- Builvero.Api.dll
Controller for profile photo upload operations
[ApiController]
[Route("api/profile/photo")]
[Authorize]
public class ProfilePhotoController : ControllerBase
- Inheritance
-
ProfilePhotoController
- Inherited Members
Constructors
ProfilePhotoController(IS3Service, ILogger<ProfilePhotoController>)
Initializes a new instance of the ProfilePhotoController class.
public ProfilePhotoController(IS3Service s3Service, ILogger<ProfilePhotoController> logger)
Parameters
s3ServiceIS3ServiceService for S3 operations including presigned URL generation.
loggerILogger<ProfilePhotoController>Logger for recording operations and errors.
Methods
GetUploadUrl(ProfilePhotoUploadUrlRequest, CancellationToken)
Generates a presigned URL for uploading a profile photo to S3.
[HttpPost("upload-url")]
public Task<ActionResult<ProfilePhotoUploadUrlResponse>> GetUploadUrl(ProfilePhotoUploadUrlRequest request, CancellationToken cancellationToken)
Parameters
requestProfilePhotoUploadUrlRequestUpload request containing file metadata (filename, content type, file size).
cancellationTokenCancellationTokenCancellation token to cancel the operation.
Returns
- Task<ActionResult<ProfilePhotoUploadUrlResponse>>
200 OK: Returns ProfilePhotoUploadUrlResponse with presigned upload URL and object key
400 Bad Request: Invalid file size (exceeds 5MB), invalid file extension, or invalid content type
Remarks
Requires authentication. Validates:
- File size must not exceed 5MB
- File extension must be jpg, jpeg, or png
- Content type must be image/jpeg, image/jpg, or image/png
The presigned URL expires after 5 minutes. The client should upload the file directly to S3 using this URL. After upload, the client should update the user's profile with the returned object key.