Class S3StorageProvider
java.lang.Object
dev.jensderuiter.minecraft_imagery.storage.S3StorageProvider
- All Implemented Interfaces:
StorageProvider
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanFetch an image from the S3 bucket.generateDownloadUrl(UUID uuid) Generate an S3 presigned url that's valid for one day.voidRemove an image from the S3 bucket.store(BufferedImage image) Store an image in the S3 bucket.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.jensderuiter.minecraft_imagery.storage.StorageProvider
getExtension, getFileName
-
Constructor Details
-
S3StorageProvider
public S3StorageProvider(String endpoint, String region, String accessKey, String secretKey, String bucket) Initialize the S3 storage provider.- Parameters:
endpoint- S3 endpoint url.region- S3 region (auto for CloudFlare R2).accessKey- S3 access key.secretKey- S3 secret key.bucket- S3 bucket.
-
-
Method Details
-
fetch
Fetch an image from the S3 bucket. Image is in PNG format (TYPE_INT_ARGB).- Specified by:
fetchin interfaceStorageProvider- Parameters:
uuid- The UUID of the image to fetch. You have saved this from the store method.- Returns:
- The image with the specified UUID.
- Throws:
StorageException- When the fetching fails.
-
store
Store an image in the S3 bucket. Will be stored as (generated uuid).png- Specified by:
storein interfaceStorageProvider- Parameters:
image- The image to store.- Returns:
- The UUID of the image you've just stored. Used to retrieve or remove the image.
- Throws:
StorageException- When storing the image fails.
-
remove
Remove an image from the S3 bucket.- Specified by:
removein interfaceStorageProvider- Parameters:
uuid- The UUID of the image to remove. You have saved this from the store method.- Throws:
StorageException- When the deletion fails.
-
downloadUrlEnabled
public boolean downloadUrlEnabled()- Specified by:
downloadUrlEnabledin interfaceStorageProvider
-
generateDownloadUrl
Generate an S3 presigned url that's valid for one day.- Specified by:
generateDownloadUrlin interfaceStorageProvider- Parameters:
uuid- The UUID of the image to fetch. You have saved this from the store method.- Returns:
- The image with the specified UUID.
- Throws:
StorageException- When the fetching fails.
-