include path for sub directories#30
Conversation
c51dec4 to
57b8b7c
Compare
57b8b7c to
9d9b119
Compare
| * @throws IOException is a file could not be stored | ||
| * @throws IOException if a file could not be stored | ||
| */ | ||
| void add(String fileUniqueName, InputStream fileData) throws IOException; |
There was a problem hiding this comment.
Sur celle là, on pourra la déprécier je pense non ? On s'était dit que ça dégagerait dans la prochaine version majeure (car finalement on garde uniquement cette méthode dans le cas hypothétique où quelqu'un aurait fait une implémentation custom de FileStorageService, ce qui est très improbable).
Pareil pour tous les copains où on ajoute les métadonnées en paramètre
De plus, ça m'ennuie de faire des requêtes aux métadonnées pour les cas où on en a pas besoin. Tu penses qu'on pourrait ajouter une méthode par défaut (par exemple onInstall ou un truc du genre), qui permettrait de refaire remonter à fileService le besoin d'utiliser ou non les métadonnées ? Comme ça, pour la majorité des cas où on n'utilise pas les sous dossiers, alors on garde un fonctionnement "le plus optimisé" possible
| .stream() | ||
| .map(FileMetadata.class::cast) | ||
| .toList(); |
There was a problem hiding this comment.
C'est hyper bizarre ce traitement
This pull request introduces support for subdirectory paths in file storage, improves file deletion logic, and adds robust path sanitization utilities. It also enhances interfaces and implementations to support these new features, while maintaining backward compatibility. Below are the key changes grouped by theme:
Subdirectory Path Support & Path Sanitization
FilePathSanitizerto securely sanitize and validate file paths, preventing path traversal and other security issues. Comprehensive unit tests for this utility were also added inFilePathSanitizerTest. [1] [2]FileStorageServiceinterface to support storing and fetching files with subdirectory paths, using file metadata to provide optional path information. New methodsadd(String, InputStream, FileMetadata)andfetch(String, FileMetadata)were added, along withdeleteFiles(List<FileMetadata>).File Deletion and Metadata Handling Improvements
FileServiceto fetch file metadata before deletion, ensuring both file data and metadata are deleted in sync and preventing unreferenced files in storage.fetchAll(List<String>)toFileMetadataServiceand its database implementation, allowing batch retrieval of file metadata by unique names. [1] [2] [3]Interface and Implementation Enhancements
FileStorageDatabaseServiceto implement the new methods fromFileStorageService, handling metadata-aware file operations and delegating appropriately for database storage (which ignores subdirectory paths). [1] [2]FileTypeDatabase,FileTypesProvider) for clarity and improved maintainability. [1] [2]Logging and Code Clean-up
@Slf4jannotation in service classes for cleaner and more concise logging. [1] [2] [3]These changes collectively improve the flexibility, security, and maintainability of the file storage subsystem, especially in environments where organizing files into subdirectories is required.