Class TransactionalFileUploader
java.lang.Object
com.example.blogs.app.api.post.service.TransactionalFileUploader
Handles file uploads with automatic rollback when database transactions fail.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionuploadWithTransactionRollback(MultipartFile file, String path) Uploads a file and registers a transaction synchronization callback to delete it if the transaction rolls back.
-
Constructor Details
-
TransactionalFileUploader
public TransactionalFileUploader()
-
-
Method Details
-
uploadWithTransactionRollback
Uploads a file and registers a transaction synchronization callback to delete it if the transaction rolls back. Ensures uploaded files are cleaned up from S3 when the associated database transaction fails.- Parameters:
file- the multipart file to uploadpath- the storage path where the file should be uploaded- Returns:
- the uploaded file entity with metadata
- Throws:
FailedToRollbackS3FileException- if the rollback cleanup fails
-