upload_files
Transfer multiple files to MinIO object storage by specifying bucket names, local file paths, and object names. Simplify batch uploads with optional metadata inclusion.
Instructions
批量上传文件
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bucketName | Yes | 存储桶名称 | |
| files | Yes | 文件列表 |
Implementation Reference
- src/minio-client.ts:269-294 (handler)Core handler function implementing batch file uploads to a MinIO bucket. Iterates over the files array, uploads each using uploadFile, and returns a BatchOperationResult with success/failure counts and errors.async uploadFiles(bucketName: string, files: Array<{ localPath: string; objectName: string; metadata?: Record<string, string> }>): Promise<BatchOperationResult> { this.ensureConnected(); const result: BatchOperationResult = { success: true, successCount: 0, failureCount: 0, errors: [] }; for (const file of files) { try { await this.uploadFile(bucketName, file.objectName, file.localPath, file.metadata); result.successCount++; } catch (error) { result.success = false; result.failureCount++; result.errors.push({ item: file.localPath, error: error instanceof Error ? error.message : String(error) }); } } return result; }
- src/index.ts:232-253 (schema)Input schema definition for the 'upload_files' tool, provided in the ListTools response. Defines parameters: bucketName (required string), files (required array of objects with localPath, objectName, optional metadata).name: 'upload_files', description: '批量上传文件', inputSchema: { type: 'object', properties: { bucketName: { type: 'string', description: '存储桶名称' }, files: { type: 'array', items: { type: 'object', properties: { localPath: { type: 'string', description: '本地文件路径' }, objectName: { type: 'string', description: '对象名称' }, metadata: { type: 'object', description: '文件元数据(可选)' } }, required: ['localPath', 'objectName'] }, description: '文件列表' } }, required: ['bucketName', 'files'] }
- src/index.ts:553-572 (handler)MCP tool dispatch handler for 'upload_files'. Parses input arguments using Zod, calls MinIOStorageClient.uploadFiles, formats and returns the batch operation result as tool response.case 'upload_files': { const { bucketName, files } = z.object({ bucketName: z.string(), files: z.array(z.object({ localPath: z.string(), objectName: z.string(), metadata: z.record(z.string()).optional() })) }).parse(args); const result = await this.minioClient.uploadFiles(bucketName, files); return { content: [ { type: 'text', text: `批量上传完成: 成功 ${result.successCount} 个, 失败 ${result.failureCount} 个${result.errors.length > 0 ? '\n错误:\n' + result.errors.map(e => `- ${e.item}: ${e.error}`).join('\n') : ''}` } ] }; }
- src/index.ts:554-561 (schema)Zod runtime validation schema for 'upload_files' arguments in the dispatch handler, matching the tool inputSchema.const { bucketName, files } = z.object({ bucketName: z.string(), files: z.array(z.object({ localPath: z.string(), objectName: z.string(), metadata: z.record(z.string()).optional() })) }).parse(args);