package setup import ( "log/slog" "github.com/dariuszjaniak/warp/server/internal/config" "github.com/dariuszjaniak/warp/server/internal/mediaapi" "github.com/dariuszjaniak/warp/server/internal/storage" "github.com/dariuszjaniak/warp/server/internal/storage/filestore" ) // newMedia builds the media repository. Its content goes to the storage // driver's own file storage if it has one, and under media.base_path if // not. func newMedia(cfg *config.Config, db storage.Database, log *slog.Logger) (*mediaapi.API, error) { var blobs storage.BlobStore if provider, ok := db.(storage.BlobProvider); ok { blobs = provider.Blobs() } else { store, err := filestore.New(cfg.Media.BasePath) if err != nil { return nil, err } blobs = store log.Debug("media is stored on the local filesystem", "path", store.Root()) } return mediaapi.New(mediaapi.Options{ ServerName: cfg.Global.ServerName, Store: db.Media(), Blobs: blobs, Config: cfg.Media, Logger: log, }) }