Skip to main content
Glama

tos_put_object

Upload objects to TOS storage by providing bucket name, object key, and content, supporting base64 encoding and content type specification.

Instructions

上传对象到 TOS

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucket_nameYes存储桶名称
contentYes文件内容(base64编码)或文本内容
content_typeNo内容类型application/octet-stream
is_base64No内容是否为base64编码
object_keyYes对象键名

Implementation Reference

  • Core handler function that executes the tos_put_object tool: extracts arguments, handles base64 or text content, calls tos_client.put_object to upload, and returns success or error message.
    async def put_object(args: Dict[str, Any]) -> List[TextContent]: """上传对象""" bucket_name = args["bucket_name"] object_key = args["object_key"] content = args["content"] content_type = args.get("content_type", "application/octet-stream") is_base64 = args.get("is_base64", False) try: if is_base64: content_bytes = base64.b64decode(content) else: content_bytes = content.encode('utf-8') resp = tos_client.put_object(bucket_name, object_key, content=content_bytes, content_type=content_type, content_length=len(content_bytes)) return [TextContent(type="text", text=f"成功上传对象: {object_key} (ETag: {resp.etag})")] except Exception as e: return [TextContent(type="text", text=f"上传对象失败: {str(e)}")]
  • Input schema definition for the tos_put_object tool, specifying parameters like bucket_name, object_key, content (base64 or text), content_type, and is_base64 flag.
    Tool( name="tos_put_object", description="上传对象到 TOS", inputSchema={ "type": "object", "properties": { "bucket_name": { "type": "string", "description": "存储桶名称" }, "object_key": { "type": "string", "description": "对象键名" }, "content": { "type": "string", "description": "文件内容(base64编码)或文本内容" }, "content_type": { "type": "string", "description": "内容类型", "default": "application/octet-stream" }, "is_base64": { "type": "boolean", "description": "内容是否为base64编码", "default": False } }, "required": ["bucket_name", "object_key", "content"] } ),
  • Registers the tool handler dispatch in the call_tool function: routes calls to name 'tos_put_object' to the put_object handler.
    elif name == "tos_put_object": return await put_object(arguments)
  • Tool registration in list_tools(): adds tos_put_object to the list of available tools with its schema and description.
    Tool( name="tos_put_object", description="上传对象到 TOS", inputSchema={ "type": "object", "properties": { "bucket_name": { "type": "string", "description": "存储桶名称" }, "object_key": { "type": "string", "description": "对象键名" }, "content": { "type": "string", "description": "文件内容(base64编码)或文本内容" }, "content_type": { "type": "string", "description": "内容类型", "default": "application/octet-stream" }, "is_base64": { "type": "boolean", "description": "内容是否为base64编码", "default": False } }, "required": ["bucket_name", "object_key", "content"] } ),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jneless/tos-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server