From 86cc2986c3af8f4908e1dfba5848f997e9c69cd4 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Mon, 22 Apr 2024 19:02:24 +0200 Subject: [PATCH] [frontend] Use content-disposition: form-data for file uploads --- Iceshrimp.Frontend/Core/Services/ApiClient.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Iceshrimp.Frontend/Core/Services/ApiClient.cs b/Iceshrimp.Frontend/Core/Services/ApiClient.cs index 81b31797..ca335228 100644 --- a/Iceshrimp.Frontend/Core/Services/ApiClient.cs +++ b/Iceshrimp.Frontend/Core/Services/ApiClient.cs @@ -83,16 +83,18 @@ internal class ApiClient(HttpClient client) if (data is IBrowserFile file) { - request.Content = new MultipartContent + request.Content = new MultipartFormDataContent { new StreamContent(file.OpenReadStream()) { Headers = { ContentType = new MediaTypeHeaderValue(file.ContentType), - ContentDisposition = new ContentDispositionHeaderValue("attachment") + ContentDisposition = new ContentDispositionHeaderValue("form-data") { - FileName = file.Name, Size = file.Size + Name = "file", + FileName = file.Name, + Size = file.Size } } }