Newer
Older
utils::{self, content_disposition::make_content_disposition},
Result,
use conduit_service::media::MXC_LENGTH;
use ruma::{api::client::media::create_content, Mxc};
///
/// Permanently save media in the server.
///
/// - Some metadata will be saved in the database
/// - Media will be saved in the media/ directory
#[tracing::instrument(skip_all, fields(%client), name = "media_upload")]
State(services): State<crate::State>, InsecureClientIp(client): InsecureClientIp,
body: Ruma<create_content::v3::Request>,
) -> Result<create_content::v3::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let content_disposition = make_content_disposition(None, body.content_type.as_deref(), body.filename.as_deref());
let mxc = Mxc {
server_name: services.globals.server_name(),
media_id: &utils::random_string(MXC_LENGTH),
};
Some(&content_disposition),
&body.file,
)
.await?;
Ok(create_content::v3::Response {