misc(ffi): Add filename to the FFI bindings too

This commit is contained in:
Jorge Martín
2025-07-22 09:54:27 +02:00
parent f072fa732e
commit cecf017603
2 changed files with 8 additions and 3 deletions

View File

@@ -1026,10 +1026,11 @@ impl Client {
&self,
mime_type: String,
data: Vec<u8>,
filename: Option<String>,
progress_watcher: Option<Box<dyn ProgressWatcher>>,
) -> Result<String, ClientError> {
let mime_type: mime::Mime = mime_type.parse().context("Parsing mime type")?;
let request = self.inner.media().upload(&mime_type, data, None);
let request = self.inner.media().upload(&mime_type, data, filename, None);
if let Some(progress_watcher) = progress_watcher {
let mut subscriber = request.subscribe_to_send_progress();

View File

@@ -219,7 +219,11 @@ pub enum UploadSource {
/// Upload source is a file on disk
File {
/// Path to file
filename: String,
path: String,
/// An optional filename, if the one in the path is not the one we want
/// to use for the file.
filename: Option<String>,
},
/// Upload source is data in memory
Data {
@@ -233,7 +237,7 @@ pub enum UploadSource {
impl From<UploadSource> for AttachmentSource {
fn from(value: UploadSource) -> Self {
match value {
UploadSource::File { filename } => Self::File(filename.into()),
UploadSource::File { path, filename } => Self::File { path: path.into(), filename },
UploadSource::Data { bytes, filename } => Self::Data { bytes, filename },
}
}