pub struct Media {Show 21 fields
pub max_pending_uploads: usize,
pub create_unused_expiration_time: u64,
pub rc_create_per_second: u32,
pub rc_create_burst_count: u32,
pub upload_min_free_space: u64,
pub deny_framing: bool,
pub deny_inline_styles: bool,
pub allow_legacy: bool,
pub request_legacy: bool,
pub freeze_legacy: bool,
pub startup_check: bool,
pub compat_file_link: bool,
pub prune_missing: bool,
pub storage_providers: BTreeSet<String>,
pub store_on_providers: BTreeSet<String>,
pub allow_redirect: bool,
pub prevent_downloads_from: RegexSet,
pub import: Import,
pub thumbnail: Thumbnail,
pub url_preview: UrlPreview,
pub video_thumbnail: VideoThumbnail,
}Expand description
Media repository
Uploads, storage, downloads and the legacy media endpoints, with
sub-sections for Conduit media import, thumbnails, URL previews and
video thumbnails. Every key has a working default; with nothing set,
media is kept in <database_path>/media by the built-in local provider
media, which a [global.storage_provider.media.local] (or .s3,
.gcs) section replaces.
Reads try the providers in storage_providers, in name order, until
one holds the file; uploads go to those in store_on_providers, or to
all of them when it is empty. Any name other than media needs its own
[global.storage_provider.<ID>.*] section.
Example (new uploads to S3, older files still read from disk):
[global.media]
storage_providers = ["media", "media_on_s3"]
store_on_providers = ["media_on_s3"]
[global.storage_provider.media_on_s3.s3]
bucket = "matrix-media"
key = "ACCESS_KEY_ID"
secret = "SECRET_ACCESS_KEY"Tips:
- The config is refused when
store_on_providersnames a provider missing fromstorage_providers, orstorage_providersnames one (other thanmedia) with no[global.storage_provider.<ID>.*]section. An S3 or GCS section withoutbucket(or S3url), or a local one withbase_path = "", passes that check but is skipped at startup; skipping is an error only when it leaves no enabled provider to receive uploads. - Several
storage_providerswithstore_on_providersempty copies every upload to all of them; a startup warning says so. - Copy existing files to a new provider with
!admin query storage sync media media_on_s3, then dropmediafrom both lists. - Provider sections are read only at startup, so a config reload that adds, removes or changes one is refused; restart instead.
Fields§
§max_pending_uploads: usizeLimits the number of concurrent pending asynchronous media uploads per user.
reloadable: yes default: 5 legacy: max_pending_media_uploads
create_unused_expiration_time: u64Sets the lifetime in seconds before an unused pending MXC URI expires and is removed.
reloadable: yes default: 86400 (24 hours) legacy: media_create_unused_expiration_time
rc_create_per_second: u32Limits media create requests per second from one user.
reloadable: yes default: 10 legacy: media_rc_create_per_second
rc_create_burst_count: u32Limits the burst count of media create requests from one user.
reloadable: yes default: 50 legacy: media_rc_create_burst_count
upload_min_free_space: u64Sets the writable space threshold below which local media uploads are refused.
Each local storage provider receiving the upload is checked, excluding blocks reserved for privileged processes. Media is stored beside the database by default, and a full disk prevents database writes, so uploads stop first with M_RESOURCE_LIMIT_EXCEEDED and resume when space returns. Remote media, URL previews, and thumbnails are never refused. Accepts an integer byte count or an SI/IEC string such as “10 GiB”; 0 disables the check for cases such as a network mount reporting no free space.
reloadable: yes default: “1 GiB” legacy: media_upload_min_free_space
deny_framing: boolPrevents media from being embedded in frames, including same-origin frames.
The default is disabled for compatibility with attachment viewers.
Enabling it adds frame-ancestors 'none' to download and thumbnail
Content-Security-Policy headers. Changes require a restart, and reverse
proxy headers may still prevent framing.
legacy: media_deny_framing
deny_inline_styles: boolPrevents inline styles in media documents.
The default is disabled so browser image viewers retain their
presentation styles. Enabling it omits style-src 'unsafe-inline' from
download and thumbnail Content-Security-Policy headers. Changes require
a restart, and reverse proxy headers may still restrict styles.
legacy: media_deny_inline_styles
allow_legacy: boolEnables the legacy unauthenticated Matrix media repository endpoints.
These are /_matrix/media/*/config, /_matrix/media/*/preview_url,
/_matrix/media/*/download/*, and /_matrix/media/*/thumbnail/*. The
authenticated equivalents are always enabled. The default is false.
legacy: allow_legacy_media
request_legacy: boolFalls back to requesting legacy unauthenticated media from remote servers.
Unauthenticated media was removed around the third quarter of 2024. Enabling this adds considerable federation requests that are unlikely to succeed.
reloadable: yes legacy: request_legacy_media
freeze_legacy: boolPermits fetching remote legacy content and thumbnails when true.
When false, those remote legacy requests are rejected.
reloadable: yes legacy: freeze_legacy_media
startup_check: boolChecks media directory consistency at startup.
Together with media.compat_file_link, this upgrades media when
switching between Conduit and tuwunel; both options must be enabled.
Startup checks can also remove database entries for files deleted from
the media directory. If neither check applies and the directory is
large, disabling this may reduce startup time.
legacy: media_startup_check
compat_file_link: boolCreates media symlinks for compatibility with Conduit’s media directory.
This is needed only when planning to use Conduit again; disabling it
reduces filesystem clutter and symlink management overhead. It is
disabled by default. Before returning to upstream Conduit, run tuwunel
at least once with this enabled and allow media.startup_check to
finish before shutdown.
legacy: media_compat_file_link
prune_missing: boolRemoves missing media metadata during startup checks.
Deleting files from the media directory then removes their corresponding database entries. This is disabled by default because accidentally moving the directory or making it inaccessible would otherwise lose database metadata.
legacy: prune_missing_media
storage_providers: BTreeSet<String>Selects storage providers used for media.
Configure each listed name at global.storage_provider.<NAME>.<brand>;
multiple entries support advanced features and future extensions, but
require checking related settings to avoid resource duplication costs
and poor performance. The default ["media"] is an implicit provider
for the local media directory. Configure
global.storage_provider.media.local to alter it, or omit “media” from
this list to disable it. Existing deployments should retain “media” as
a fallback alongside a new provider.
reloadable: yes default: [“media”] legacy: media_storage_providers
store_on_providers: BTreeSet<String>Selects configured storage providers that receive new media.
When not explicitly configured, all entries in
media.storage_providers are used. Each selected provider must also
appear there. This supports passive migration by writing to a new
provider while querying the old one as a fallback, for example
media.storage_providers = ["media", "media_on_s3"] with
media.store_on_providers = ["media_on_s3"].
reloadable: yes default: [] legacy: store_media_on_providers
allow_redirect: boolRedirects local media downloads when the client requests
allow_redirect=true under MSC3860.
If a configured provider can presign the object, such as S3, the server returns a 307 redirect to a short-lived URL instead of proxying the bytes. Media stored only on the local filesystem is always served directly.
reloadable: yes default: false legacy: media_allow_redirect
prevent_downloads_from: RegexSetLists server-name regex patterns from which remote media downloads are refused.
reloadable: yes example: [‘badserver.tld$’, ‘badphrase’, ‘19dollarfortnitecards’]
default: [] legacy: prevent_media_downloads_from
import: ImportSettings for media import.
display: section
thumbnail: ThumbnailSettings for media thumbnail.
display: section
url_preview: UrlPreviewSettings for media url preview.
display: section
video_thumbnail: VideoThumbnailSettings for media video thumbnail.
display: section
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Media
impl<'de> Deserialize<'de> for Media
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Media
impl RefUnwindSafe for Media
impl Send for Media
impl Sync for Media
impl Unpin for Media
impl UnsafeUnpin for Media
impl UnwindSafe for Media
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> ExpectInto for T
impl<T> ExpectInto for T
Source§impl<T> Expected for T
impl<T> Expected for T
Source§fn expected_add(self, rhs: Self) -> Selfwhere
Self: CheckedAdd + Sized,
fn expected_add(self, rhs: Self) -> Selfwhere
Self: CheckedAdd + Sized,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_sub(self, rhs: Self) -> Selfwhere
Self: CheckedSub + Sized,
fn expected_sub(self, rhs: Self) -> Selfwhere
Self: CheckedSub + Sized,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_mul(self, rhs: Self) -> Selfwhere
Self: CheckedMul + Sized,
fn expected_mul(self, rhs: Self) -> Selfwhere
Self: CheckedMul + Sized,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_div(self, rhs: Self) -> Selfwhere
Self: CheckedDiv + Sized,
fn expected_div(self, rhs: Self) -> Selfwhere
Self: CheckedDiv + Sized,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_rem(self, rhs: Self) -> Selfwhere
Self: CheckedRem + Sized,
fn expected_rem(self, rhs: Self) -> Selfwhere
Self: CheckedRem + Sized,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> JsonCastable<CanonicalJsonValue> for T
impl<T> JsonCastable<Value> for T
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
§fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
§fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
§fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read moreSource§impl<T> Tried for T
impl<T> Tried for T
Source§fn try_add(self, rhs: Self) -> Result<Self>where
Self: CheckedAdd + Sized,
fn try_add(self, rhs: Self) -> Result<Self>where
Self: CheckedAdd + Sized,
rhs with checked arithmetic. Read moreSource§fn try_sub(self, rhs: Self) -> Result<Self>where
Self: CheckedSub + Sized,
fn try_sub(self, rhs: Self) -> Result<Self>where
Self: CheckedSub + Sized,
rhs with checked arithmetic. Read moreSource§fn try_mul(self, rhs: Self) -> Result<Self>where
Self: CheckedMul + Sized,
fn try_mul(self, rhs: Self) -> Result<Self>where
Self: CheckedMul + Sized,
rhs with checked arithmetic. Read more