Package com.onec.ui.media
Interface MediaStorage
- All Known Implementing Classes:
FilesystemMediaStorage
public interface MediaStorage
Pluggable backend for binary uploads — the SPI behind
POST /api/media. The framework
ships a FilesystemMediaStorage default; an application (or a commercial connector) swaps
in S3-compatible object storage simply by exposing its own MediaStorage bean, which the
auto-configuration's @ConditionalOnMissingBean default then steps aside for.
Implementations must stream the content rather than buffer it whole, so multi-megabyte uploads
don't sit in memory. The returned url is what callers persist; it must
resolve back to the bytes (via load(java.lang.String) for framework-served backends, or directly for
backends that hand out their own URLs).
-
Method Summary
Modifier and TypeMethodDescriptiondefault Optional<LoadedMedia> Read 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.
-
Method Details
-
store
StoredMedia store(InputStream content, String filename, String contentType, long size) throws IOException Persist an uploaded binary and return a reference to it.- 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
Read 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.- Parameters:
key- thekeyproduced by a priorstore(java.io.InputStream, java.lang.String, java.lang.String, long)
-