Package com.onec.ui.media
Class FilesystemMediaStorage
java.lang.Object
com.onec.ui.media.FilesystemMediaStorage
- All Implemented Interfaces:
MediaStorage
The default
MediaStorage: streams uploads to a directory tree on disk and serves them
back through GET /api/media/{key}. Keys are date-sharded (yyyy/MM/<uuid>.<ext>)
so a single directory never accumulates unbounded entries and the stored name leaks nothing about
the original. Suitable for single-node deployments and development; multi-node setups should swap
in an object-store backend by exposing their own MediaStorage bean.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRead a previously stored binary back for serving byGET /api/media/{key}.store(InputStream content, String filename, String contentType, long size) Persist an uploaded binary and return a reference to it.
-
Constructor Details
-
FilesystemMediaStorage
-
-
Method Details
-
store
public StoredMedia store(InputStream content, String filename, String contentType, long size) throws IOException Description copied from interface:MediaStoragePersist an uploaded binary and return a reference to it.- Specified by:
storein interfaceMediaStorage- Parameters:
content- the file bytes; the implementation reads (and the caller closes) this streamfilename- the original client filename, already sanitized to a bare name (may be blank)contentType- the validated content type (nevernull/blank)size- the declared size in bytes, or-1if the client didn't report one- Throws:
IOException
-
load
Description copied from interface:MediaStorageRead a previously stored binary back for serving byGET /api/media/{key}. The default returns empty, which makes that endpoint answer 404 — appropriate for backends whoseurlalready points at a directly reachable object-store address.- Specified by:
loadin interfaceMediaStorage- Parameters:
key- thekeyproduced by a priorMediaStorage.store(java.io.InputStream, java.lang.String, java.lang.String, long)
-