2
0
mirror of synced 2025-01-11 09:06:56 +00:00

sets content-type correctly

This commit is contained in:
Ben 2024-10-30 08:40:46 +01:00
parent b8d6ac929b
commit ff4711e802
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
2 changed files with 5 additions and 5 deletions

View File

@ -140,7 +140,7 @@ namespace CodexPlugin
public ContentId UploadFile(TrackedFile file, Action<Failure> onFailure)
{
return UploadFile(file, "random-test-data", "random-test-data", onFailure);
return UploadFile(file, "application/x-binary", $"attachment; filename=\"{file.Filename}\"", onFailure);
}
public ContentId UploadFile(TrackedFile file, string contentType, string contentDisposition, Action<Failure> onFailure)

View File

@ -119,7 +119,7 @@ namespace AutoClient
{
var info = new FileInfo(filename);
var sw = System.Diagnostics.Stopwatch.StartNew();
var cid = await UploadStream(fileStream);
var cid = await UploadStream(fileStream, filename);
var time = sw.Elapsed;
app.Performance.UploadSuccessful(info.Length, time);
app.CidRepo.Add(nodeId, cid.Id, info.Length);
@ -132,12 +132,12 @@ namespace AutoClient
}
}
private async Task<ContentId> UploadStream(FileStream fileStream)
private async Task<ContentId> UploadStream(FileStream fileStream, string filename)
{
log.Debug($"Uploading file...");
var response = await codex.UploadAsync(
content_type: "autoclient-test-content",
content_disposition: "autoclient-test-content",
content_type: "application/x-binary",
content_disposition: $"attachment; filename=\"{filename}\"",
fileStream, app.Cts.Token);
if (string.IsNullOrEmpty(response)) FrameworkAssert.Fail("Received empty response.");