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 Type
    Method
    Description
    load(String key)
    Read a previously stored binary back for serving by GET /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 stream
      filename - the original client filename, already sanitized to a bare name (may be blank)
      contentType - the validated content type (never null/blank)
      size - the declared size in bytes, or -1 if the client didn't report one
      Throws:
      IOException
    • load

      default Optional<LoadedMedia> load(String key)
      Read a previously stored binary back for serving by GET /api/media/{key}. The default returns empty, which makes that endpoint answer 404 — appropriate for backends whose url already points at a directly reachable object-store address.
      Parameters:
      key - the key produced by a prior store(java.io.InputStream, java.lang.String, java.lang.String, long)