diff --git a/src/AnthropicClient/Models/AnthropicFile.cs b/src/AnthropicClient/Models/AnthropicFile.cs
index 0cc2ca6..a736a39 100644
--- a/src/AnthropicClient/Models/AnthropicFile.cs
+++ b/src/AnthropicClient/Models/AnthropicFile.cs
@@ -9,14 +9,12 @@ public class AnthropicFile
{
///
/// Unique object identifier.
- /// The format and length of IDs may change over time.
///
[JsonPropertyName("id")]
public string Id { get; init; } = string.Empty;
///
/// Object type.
- /// For files, this is always "file".
///
[JsonPropertyName("type")]
public string Type { get; init; } = "file";
@@ -24,26 +22,26 @@ public class AnthropicFile
///
/// Original filename of the uploaded file.
///
- [JsonPropertyName("file_name")]
- public string FileName { get; init; } = string.Empty;
+ [JsonPropertyName("filename")]
+ public string Name { get; init; } = string.Empty;
///
- /// RFC 3339 datetime string representing when the file was created.
+ /// Date file was created.
///
[JsonPropertyName("created_at")]
- public string CreatedAt { get; init; } = string.Empty;
+ public DateTimeOffset CreatedAt { get; init; }
///
/// Size of the file in bytes.
///
[JsonPropertyName("size_bytes")]
- public long SizeBytes { get; init; }
+ public long Size { get; init; }
///
/// MIME type of the file.
///
- [JsonPropertyName("file_type")]
- public string FileType { get; init; } = string.Empty;
+ [JsonPropertyName("mime_type")]
+ public string MimeType { get; init; } = string.Empty;
///
/// Whether the file can be downloaded.
diff --git a/tests/AnthropicClient.Tests/Integration/AnthropicApiClientTests.cs b/tests/AnthropicClient.Tests/Integration/AnthropicApiClientTests.cs
index 6cab022..ff05315 100644
--- a/tests/AnthropicClient.Tests/Integration/AnthropicApiClientTests.cs
+++ b/tests/AnthropicClient.Tests/Integration/AnthropicApiClientTests.cs
@@ -1928,4 +1928,41 @@ public class AnthropicApiClientTests : IntegrationTest
result.Value.Id.Should().Be(batchId);
result.Value.Type.Should().Be("message_batch_deleted");
}
+
+ [Fact]
+ public async Task CreateFileAsync_WhenCalled_ItShouldReturnFile()
+ {
+ _mockHttpMessageHandler
+ .WhenCreateFileRequest()
+ .Respond(
+ HttpStatusCode.OK,
+ "application/json",
+ @"{
+ ""created_at"": ""2023-11-07T05:31:56Z"",
+ ""downloadable"": false,
+ ""filename"": ""example.txt"",
+ ""id"": ""file_013Zva2CMHLNnXjNJJKqJ2EF"",
+ ""mime_type"": ""text/plain"",
+ ""size_bytes"": 1234,
+ ""type"": ""file""
+ }"
+ );
+
+ var fileContent = new MemoryStream(Encoding.UTF8.GetBytes("Example file content"));
+ var request = new CreateFileRequest(fileContent, "example.txt", "text/plain");
+
+ var result = await Client.CreateFileAsync(request);
+
+ result.IsSuccess.Should().BeTrue();
+ result.Value.Should().BeEquivalentTo(new AnthropicFile()
+ {
+ CreatedAt = DateTimeOffset.Parse("2023-11-07T05:31:56Z"),
+ Downloadable = false,
+ Name = "example.txt",
+ Id = "file_013Zva2CMHLNnXjNJJKqJ2EF",
+ MimeType = "text/plain",
+ Size = 1234,
+ Type = "file"
+ });
+ }
}
\ No newline at end of file
diff --git a/tests/AnthropicClient.Tests/Integration/IntegrationTest.cs b/tests/AnthropicClient.Tests/Integration/IntegrationTest.cs
index 223107b..f618b44 100644
--- a/tests/AnthropicClient.Tests/Integration/IntegrationTest.cs
+++ b/tests/AnthropicClient.Tests/Integration/IntegrationTest.cs
@@ -20,6 +20,7 @@ public static class MockHttpMessageHandlerExtensions
private static readonly string CountTokensEndpoint = $"{BaseUrl}/messages/count_tokens";
private static readonly string MessageBatchesEndpoint = $"{BaseUrl}/messages/batches";
private static readonly string ModelsEndpoint = $"{BaseUrl}/models";
+ private static readonly string FilesEndpoint = $"{BaseUrl}/files";
private static MockedRequest SetupBaseRequest(
this MockHttpMessageHandler mockHttpMessageHandler,
@@ -103,4 +104,10 @@ public static class MockHttpMessageHandlerExtensions
return mockHttpMessageHandler
.SetupBaseRequest(HttpMethod.Delete, $"{MessageBatchesEndpoint}/{batchId}");
}
+
+ public static MockedRequest WhenCreateFileRequest(this MockHttpMessageHandler mockHttpMessageHandler)
+ {
+ return mockHttpMessageHandler
+ .SetupBaseRequest(HttpMethod.Post, FilesEndpoint);
+ }
}
\ No newline at end of file