Skip to content

Commit

Permalink
sets content-type correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
benbierens committed Oct 30, 2024
1 parent b8d6ac9 commit ff4711e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ProjectPlugins/CodexPlugin/CodexNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public ContentId UploadFile(TrackedFile file)

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)
Expand Down
8 changes: 4 additions & 4 deletions Tools/AutoClient/Purchaser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private async Task<ContentId> UploadFile(string filename)
{
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);
Expand All @@ -132,12 +132,12 @@ private async Task<ContentId> UploadFile(string filename)
}
}

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.");
Expand Down

0 comments on commit ff4711e

Please sign in to comment.