pleroma: add filename parameter
This commit is contained in:
parent
616837db6d
commit
c38829a1b2
1 changed files with 6 additions and 6 deletions
|
@ -358,7 +358,7 @@ public class Pleroma
|
|||
/// <param name="mime">The MIME type of the file.</param>
|
||||
/// <param name="file">An array containing the file's contents.</param>
|
||||
/// <returns>A handle of the uploaded file, including its ID and URLs.</returns>
|
||||
public Task<Attachment> Upload(CommonMIMEs mime, byte[] file) => Upload(CommonMIMEString(mime), file);
|
||||
public Task<Attachment> Upload(CommonMIMEs mime, byte[] file, string name = "file") => Upload(CommonMIMEString(mime), file, name);
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
|||
/// <param name="mime">The MIME type of the file.</param>
|
||||
/// <param name="file">An array containing the file's contents.</param>
|
||||
/// <returns>A handle of the uploaded file, including its ID and URLs.</returns>
|
||||
public Task<Attachment> Upload(string mime, byte[] file) => Upload(mime, new ByteArrayContent(file));
|
||||
public Task<Attachment> Upload(string mime, byte[] file, string name = "file") => Upload(mime, new ByteArrayContent(file), name);
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
|||
/// <param name="mime">The MIME type of the file.</param>
|
||||
/// <param name="stream">A stream of the file's contents.</param>
|
||||
/// <returns>A handle of the uploaded file, including its ID and URLs.</returns>
|
||||
public Task<Attachment> Upload(CommonMIMEs mime, Stream stream) => Upload(CommonMIMEString(mime), stream);
|
||||
public Task<Attachment> Upload(CommonMIMEs mime, Stream stream, string name = "file") => Upload(CommonMIMEString(mime), stream, name);
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
|||
/// <param name="mime">The MIME type of the file.</param>
|
||||
/// <param name="stream">A stream of the file's contents.</param>
|
||||
/// <returns>A handle of the uploaded file, including its ID and URLs.</returns>
|
||||
public Task<Attachment> Upload(string mime, Stream stream) => Upload(mime, new StreamContent(stream));
|
||||
public Task<Attachment> Upload(string mime, Stream stream, string name = "file") => Upload(mime, new StreamContent(stream), name);
|
||||
|
||||
async Task<Attachment> Upload(string mime, HttpContent content)
|
||||
async Task<Attachment> Upload(string mime, HttpContent content, string name)
|
||||
{
|
||||
return (await Retry<Attachment>(() =>
|
||||
{
|
||||
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue