diff --git a/osu.Framework/IO/Network/WebRequest.cs b/osu.Framework/IO/Network/WebRequest.cs
index 4fff194c84..e3d5a91b48 100644
--- a/osu.Framework/IO/Network/WebRequest.cs
+++ b/osu.Framework/IO/Network/WebRequest.cs
@@ -119,7 +119,7 @@ public class WebRequest : IDisposable
///
/// FILE parameters.
///
- private readonly IDictionary files = new Dictionary();
+ private readonly List files = new List();
///
/// The request headers.
@@ -349,9 +349,9 @@ private async Task internalPerform(CancellationToken cancellationToken = default
foreach (var p in files)
{
- var byteContent = new ByteArrayContent(p.Value);
+ var byteContent = new ByteArrayContent(p.Content);
byteContent.Headers.Add("Content-Type", "application/octet-stream");
- formData.Add(byteContent, p.Key, p.Key);
+ formData.Add(byteContent, p.ParamName, p.Filename);
}
postContent = await formData.ReadAsStreamAsync(linkedToken.Token).ConfigureAwait(false);
@@ -662,17 +662,21 @@ public void AddRaw(Stream stream)
}
///
- /// Add a new FILE parameter to this request. Replaces any existing file with the same name.
+ /// Add a new FILE parameter to this request.
/// This may not be used in conjunction with . GET requests may not contain files.
///
- /// The name of the file. This becomes the name of the file in a multi-part form POST content.
+ /// The name of the form parameter of the request that the file relates to.
/// The file data.
- public void AddFile(string name, byte[] data)
+ ///
+ /// The filename of the file to be sent to be reported to the server in the Content-Disposition header.
+ /// blob is used by default if omitted, to mirror browser behaviour.
+ ///
+ public void AddFile(string paramName, byte[] data, string filename = "blob")
{
- ArgumentNullException.ThrowIfNull(name);
+ ArgumentNullException.ThrowIfNull(paramName);
ArgumentNullException.ThrowIfNull(data);
- files[name] = data;
+ files.Add(new FormFile(paramName, data, filename));
}
///
@@ -931,5 +935,7 @@ protected override void Dispose(bool disposing)
baseStream.Dispose();
}
}
+
+ private record struct FormFile(string ParamName, byte[] Content, string Filename);
}
}