From c38829a1b2045689d9b0d71bf31aab7c28b4e2c3 Mon Sep 17 00:00:00 2001 From: uwaa Date: Tue, 14 Jan 2025 11:58:51 +0000 Subject: [PATCH] pleroma: add filename parameter --- Pleroma/Pleroma.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Pleroma/Pleroma.cs b/Pleroma/Pleroma.cs index d5475a1..daee850 100644 --- a/Pleroma/Pleroma.cs +++ b/Pleroma/Pleroma.cs @@ -358,7 +358,7 @@ public class Pleroma /// The MIME type of the file. /// An array containing the file's contents. /// A handle of the uploaded file, including its ID and URLs. - public Task Upload(CommonMIMEs mime, byte[] file) => Upload(CommonMIMEString(mime), file); + public Task Upload(CommonMIMEs mime, byte[] file, string name = "file") => Upload(CommonMIMEString(mime), file, name); /// /// Uploads a file to the server. The resulting attachment can then be included in a status as an attachment. @@ -366,7 +366,7 @@ public class Pleroma /// The MIME type of the file. /// An array containing the file's contents. /// A handle of the uploaded file, including its ID and URLs. - public Task Upload(string mime, byte[] file) => Upload(mime, new ByteArrayContent(file)); + public Task Upload(string mime, byte[] file, string name = "file") => Upload(mime, new ByteArrayContent(file), name); /// /// Uploads a file to the server. The resulting attachment can then be included in a status as an attachment. @@ -374,7 +374,7 @@ public class Pleroma /// The MIME type of the file. /// A stream of the file's contents. /// A handle of the uploaded file, including its ID and URLs. - public Task Upload(CommonMIMEs mime, Stream stream) => Upload(CommonMIMEString(mime), stream); + public Task Upload(CommonMIMEs mime, Stream stream, string name = "file") => Upload(CommonMIMEString(mime), stream, name); /// /// Uploads a file to the server. The resulting attachment can then be included in a status as an attachment. @@ -382,9 +382,9 @@ public class Pleroma /// The MIME type of the file. /// A stream of the file's contents. /// A handle of the uploaded file, including its ID and URLs. - public Task Upload(string mime, Stream stream) => Upload(mime, new StreamContent(stream)); + public Task Upload(string mime, Stream stream, string name = "file") => Upload(mime, new StreamContent(stream), name); - async Task Upload(string mime, HttpContent content) + async Task Upload(string mime, HttpContent content, string name) { return (await Retry(() => { @@ -392,7 +392,7 @@ public class Pleroma content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "\"file\"", - FileName = $"\"{Random.Shared.NextInt64()}\"", + FileName = $"\"{name}\"", }; MultipartFormDataContent form = [content];