Skip to content

Commit 1a12ba3

Browse files
mgoldenbergpoljar
authored andcommitted
feat(ffi): allow file data to be passed through bindings when sending attachment
Signed-of-by: Michael Goldenberg <[email protected]>
1 parent d9f2588 commit 1a12ba3

File tree

1 file changed

+9
-3
lines changed
  • bindings/matrix-sdk-ffi/src/timeline

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use matrix_sdk::{
3232
},
3333
};
3434
use matrix_sdk_ui::timeline::{
35-
self, EventItemOrigin, Profile, RepliedToEvent, TimelineDetails,
35+
self, AttachmentSource, EventItemOrigin, Profile, RepliedToEvent, TimelineDetails,
3636
TimelineUniqueId as SdkTimelineUniqueId,
3737
};
3838
use mime::Mime;
@@ -130,8 +130,12 @@ impl Timeline {
130130
.reply(params.reply_params.map(|p| p.try_into()).transpose()?);
131131

132132
let handle = SendAttachmentJoinHandle::new(get_runtime_handle().spawn(async move {
133-
let mut request =
134-
self.inner.send_attachment(params.filename, mime_type, attachment_config);
133+
let source = if let Some(bytes) = params.file_data {
134+
AttachmentSource::Data { bytes, filename: params.filename }
135+
} else {
136+
AttachmentSource::File(params.filename.into())
137+
};
138+
let mut request = self.inner.send_attachment(source, mime_type, attachment_config);
135139

136140
if params.use_send_queue {
137141
request = request.use_send_queue();
@@ -203,6 +207,8 @@ fn build_thumbnail_info(
203207
pub struct UploadParameters {
204208
/// Filename (previously called "url") for the media to be sent.
205209
filename: String,
210+
/// Optional file data - if not present, then data is read from `filename`
211+
file_data: Option<Vec<u8>>,
206212
/// Optional non-formatted caption, for clients that support it.
207213
caption: Option<String>,
208214
/// Optional HTML-formatted caption, for clients that support it.

0 commit comments

Comments
 (0)