Class FileServiceImpl
java.lang.Object
com.example.blogs.app.api.file.service.FileServiceImpl
- All Implemented Interfaces:
FileService
Orchestrates file upload operations by coordinating storage upload and metadata persistence.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(FileEntity fileEntity) Deletes a file from S3 storage and removes its metadata from the repository.upload(MultipartFile file, String filePath) Uploads a file to S3 storage and saves its metadata to the repository.
-
Constructor Details
-
FileServiceImpl
public FileServiceImpl()
-
-
Method Details
-
upload
Uploads a file to S3 storage and saves its metadata to the repository. Generates a unique identifier, normalizes the path, detects content type, and uploads to S3.- Specified by:
uploadin interfaceFileService- Parameters:
file- the multipart file to uploadfilePath- the storage path where the file should be uploaded- Returns:
- the saved file entity with metadata
- Throws:
FailedToUploadFileException- if the S3 upload fails
-
delete
Deletes a file from S3 storage and removes its metadata from the repository. Removes the file from S3 bucket first, then deletes the metadata record.- Specified by:
deletein interfaceFileService- Parameters:
fileEntity- the file entity to delete
-