Anthropic::FileUpload
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_name: "My Skill"
)
Constants
CONTENT_TYPES = {".py" => "text/x-python", ".js" => "text/javascript", ".mjs" => "text/javascript", ".ts" => "text/typescript", ".rb" => "text/x-ruby", ".cr" => "text/x-crystal", ".md" => "text/markdown", ".txt" => "text/plain", ".json" => "application/json", ".yaml" => "text/yaml", ".yml" => "text/yaml", ".html" => "text/html", ".htm" => "text/html", ".css" => "text/css", ".xml" => "application/xml", ".sh" => "text/x-shellscript", ".pdf" => "application/pdf", ".csv" => "text/csv", ".jpg" => "image/jpeg", ".jpeg" => "image/jpeg", ".png" => "image/png", ".gif" => "image/gif", ".webp" => "image/webp"}
Extension to content-type mapping for uploads.
Constructors
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"
)
Class methods
Instance methods
content_type
Sourcefilename
Sourceio
Source