struct

Anthropic::FileUpload

Inherits Struct < Value < Object

Represents a file to be uploaded to the Skills API

file = Anthropic::FileUpload.new(
  io: File.open("tool.py"),
  filename: "tool.py",
  content_type: "text/x-python"
)

skill = client.beta.skills.create(
  files: [file],
  display_title: "My Skill"
)

Constructors

from_path(path : String, content_type : String | Nil = nil, filename : String | Nil = nil) : self

Create from a file path with auto-detected content type

Content type is inferred from the file extension. You can override it explicitly, or provide a custom filename for the upload.

# Auto-detect content type from extension
file = Anthropic::FileUpload.from_path("src/tool.py")

# Override filename (e.g. for skill directory structure)
file = Anthropic::FileUpload.from_path(
  "src/tool.py",
  filename: "skill-name/tool.py"
)

# Override content type explicitly
file = Anthropic::FileUpload.from_path(
  "data/config",
  content_type: "application/json"
)
Source
new(io : IO, filename : String, content_type : String)
Source

Class methods

content_type_for(extension : String) : String

Infer content type from a file extension

Source

Instance methods

content_type
Source
filename
Source