Class S3ObjectKeyExtractor
- Namespace
- Builvero.Application.Utilities
- Assembly
- Builvero.Application.dll
Utility class for extracting S3 object keys from stored values. Handles various formats: full S3 URLs, presigned URLs, and object keys.
public static class S3ObjectKeyExtractor
- Inheritance
-
S3ObjectKeyExtractor
- Inherited Members
Methods
ExtractObjectKey(string?)
Extracts the S3 object key from a stored value, which may be:
- A full S3 URL (https://bucket.s3.region.amazonaws.com/profile-photos/...)
- A presigned URL (https://bucket.s3.region.amazonaws.com/profile-photos/...?X-Amz-...)
- An object key (profile-photos/user-id/photo.jpg)
public static string? ExtractObjectKey(string? storedValue)
Parameters
storedValuestringThe stored value from the database
Returns
- string
The extracted object key, or null if the value is not a valid S3 reference
IsExternalUrl(string?)
Checks if a URL is an external URL (not an S3 URL). External URLs are URLs that don't match S3 patterns and should be returned as-is.
public static bool IsExternalUrl(string? url)
Parameters
urlstringThe URL to check
Returns
- bool
True if the URL is an external URL (not S3), false otherwise