Skip to content

Commit cecf017

Browse files
committed
misc(ffi): Add filename to the FFI bindings too
1 parent f072fa7 commit cecf017

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

bindings/matrix-sdk-ffi/src/client.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,10 +1026,11 @@ impl Client {
10261026
&self,
10271027
mime_type: String,
10281028
data: Vec<u8>,
1029+
filename: Option<String>,
10291030
progress_watcher: Option<Box<dyn ProgressWatcher>>,
10301031
) -> Result<String, ClientError> {
10311032
let mime_type: mime::Mime = mime_type.parse().context("Parsing mime type")?;
1032-
let request = self.inner.media().upload(&mime_type, data, None);
1033+
let request = self.inner.media().upload(&mime_type, data, filename, None);
10331034

10341035
if let Some(progress_watcher) = progress_watcher {
10351036
let mut subscriber = request.subscribe_to_send_progress();

bindings/matrix-sdk-ffi/src/timeline/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ pub enum UploadSource {
219219
/// Upload source is a file on disk
220220
File {
221221
/// Path to file
222-
filename: String,
222+
path: String,
223+
224+
/// An optional filename, if the one in the path is not the one we want
225+
/// to use for the file.
226+
filename: Option<String>,
223227
},
224228
/// Upload source is data in memory
225229
Data {
@@ -233,7 +237,7 @@ pub enum UploadSource {
233237
impl From<UploadSource> for AttachmentSource {
234238
fn from(value: UploadSource) -> Self {
235239
match value {
236-
UploadSource::File { filename } => Self::File(filename.into()),
240+
UploadSource::File { path, filename } => Self::File { path: path.into(), filename },
237241
UploadSource::Data { bytes, filename } => Self::Data { bytes, filename },
238242
}
239243
}

0 commit comments

Comments
 (0)