class

Anthropic::Files::API

Inherits Reference < Object

Constants

ENDPOINT = "/v1/files"

Constructors

new(client : Client)
Source

Instance methods

delete(file_id : String, request_options : RequestOptions | Nil = nil) : FileDeleted

Delete a file.

Source
download(file_id : String, request_options : RequestOptions | Nil = nil) : Bytes

Download file content as raw bytes.

Source
download_base64(file_id : String, request_options : RequestOptions | Nil = nil) : String

Download file content as base64.

Source
download_string(file_id : String, request_options : RequestOptions | Nil = nil) : String

Download file content as string.

Source
list(params : ListParams = ListParams.new, request_options : RequestOptions | Nil = nil) : Page(File)

List all files with pagination.

Source
list_all(limit : Int32 | Nil = nil, request_options : RequestOptions | Nil = nil) : AutoPaginator(File)

Auto-paginating iterator for listing all files. Returns an AutoPaginator that fetches pages lazily as you iterate.

Example:

client.files.list_all(limit: 20).each do |file|
  puts file.filename
end
Source
retrieve(file_id : String, request_options : RequestOptions | Nil = nil) : File

Retrieve a specific file by ID.

Source
upload(request : UploadFileRequest, request_options : RequestOptions | Nil = nil) : File

Upload a file.

Source
upload(filename : String, content : String, mime_type : String | Nil = nil, request_options : RequestOptions | Nil = nil) : File

Upload a file from a string.

Source