ruma_client_api/media/
create_mxc_uri.rs

1//! `POST /_matrix/media/*/create`
2//!
3//! Create an MXC URI without content.
4
5pub mod v1 {
6    //! `/v1/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixmediav1create
9
10    use ruma_common::{
11        MilliSecondsSinceUnixEpoch, OwnedMxcUri,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    metadata! {
17        method: POST,
18        rate_limited: true,
19        authentication: AccessToken,
20        history: {
21            unstable("fi.mau.msc2246") => "/_matrix/media/unstable/fi.mau.msc2246/create",
22            1.7 => "/_matrix/media/v1/create",
23        }
24    }
25
26    /// Request type for the `create_mxc_uri` endpoint.
27    #[request(error = crate::Error)]
28    #[derive(Default)]
29    pub struct Request {}
30
31    /// Response type for the `create_mxc_uri` endpoint.
32    #[response(error = crate::Error)]
33    pub struct Response {
34        /// The MXC URI for the about to be uploaded content.
35        pub content_uri: OwnedMxcUri,
36
37        /// The time at which the URI will expire if an upload has not been started.
38        #[serde(skip_serializing_if = "Option::is_none")]
39        pub unused_expires_at: Option<MilliSecondsSinceUnixEpoch>,
40    }
41
42    impl Response {
43        /// Creates a new `Response` with the given MXC URI.
44        pub fn new(content_uri: OwnedMxcUri) -> Self {
45            Self { content_uri, unused_expires_at: None }
46        }
47    }
48}