Loading...
Loading...
Compare original and translation side by side
filefilefileNameclient.files.upload()mcp_imagekit_api_executefilefilefileNamemcp_imagekit_api_executeclient.files.upload()async function run(client) {
const file = await client.files.upload({
file: 'https://example.com/photo.jpg', // URL string ONLY — no local paths
fileName: 'photo.jpg',
folder: '/products',
tags: ['product', 'featured'],
});
return { fileId: file.fileId, url: file.url, size: file.size, fileType: file.fileType };
}async function run(client) {
const file = await client.files.upload({
file: 'https://example.com/photo.jpg', // 仅支持URL字符串——不允许本地路径
fileName: 'photo.jpg',
folder: '/products',
tags: ['product', 'featured'],
});
return { fileId: file.fileId, url: file.url, size: file.size, fileType: file.fileType };
}FileUploadV1| Parameter | Description |
|---|---|
| Publicly accessible URL of the file to upload. Local paths are NOT allowed. |
| Name for the uploaded file, e.g. |
| Destination folder in ImageKit (default: |
| Array of tags (e.g. |
| Mark file as private |
| Publish the file; |
| Add a unique suffix to the filename (default |
| Overwrite an existing file at the same path |
| Overwrite existing AITags when replacing |
| Overwrite existing tags when replacing |
| Overwrite existing customMetadata when replacing |
| Description for the file |
| Important area: |
| Object of custom metadata, e.g. |
| Array of extensions, e.g. |
| Object of pre/post transformations, e.g. |
| URL to receive extension completion status |
| Fields to include in the response (e.g. |
| Server-side upload check expression |
FileUploadV1| 参数 | 说明 |
|---|---|
| 待上传文件的可公开访问URL。不允许使用本地路径。 |
| 上传后的文件名,例如 |
| ImageKit中的目标文件夹(默认值: |
| 标签数组(例如 |
| 将文件标记为私有 |
| 发布文件;设为 |
| 为文件名添加唯一后缀(默认值 |
| 覆盖同一路径下的现有文件 |
| 替换文件时覆盖现有AITags |
| 替换文件时覆盖现有标签 |
| 替换文件时覆盖现有自定义元数据 |
| 文件描述 |
| 重点区域: |
| 自定义元数据对象,例如 |
| 扩展功能数组,例如 |
| 预处理/后处理转换配置,例如 |
| 接收扩展功能完成状态的URL |
| 响应中需包含的字段(例如 |
| 服务器端上传校验表达式 |
// Basic upload to a folder with tags
await client.files.upload({
file: 'https://example.com/photo.jpg',
fileName: 'photo.jpg',
folder: '/products',
tags: ['product', 'featured'],
});
// Overwrite an exact-named file
await client.files.upload({
file: 'https://example.com/banner.jpg',
fileName: 'banner.jpg',
useUniqueFileName: false,
overwriteFile: true,
});
// Upload with auto-tagging extension
await client.files.upload({
file: 'https://example.com/photo.jpg',
fileName: 'photo.jpg',
extensions: [{ name: 'google-auto-tagging', maxTags: 5 }],
});
// Upload with custom metadata and a pre-transformation
await client.files.upload({
file: 'https://example.com/photo.jpg',
fileName: 'photo.jpg',
customMetadata: { brand: 'Nike' },
transformation: { pre: 'w-1200,q-80' },
});// 基础上传:指定文件夹并添加标签
await client.files.upload({
file: 'https://example.com/photo.jpg',
fileName: 'photo.jpg',
folder: '/products',
tags: ['product', 'featured'],
});
// 覆盖同名文件
await client.files.upload({
file: 'https://example.com/banner.jpg',
fileName: 'banner.jpg',
useUniqueFileName: false,
overwriteFile: true,
});
// 上传时启用自动标签扩展
await client.files.upload({
file: 'https://example.com/photo.jpg',
fileName: 'photo.jpg',
extensions: [{ name: 'google-auto-tagging', maxTags: 5 }],
});
// 上传时添加自定义元数据并配置预处理
await client.files.upload({
file: 'https://example.com/photo.jpg',
fileName: 'photo.jpg',
customMetadata: { brand: 'Nike' },
transformation: { pre: 'w-1200,q-80' },
});folder/fileNamea-zA-Z0-9.-_useUniqueFileNametrueuseUniqueFileName: falseoverwriteFile: truecustomMetadatafolder/fileNamea-zA-Z0-9.-_useUniqueFileNametrueuseUniqueFileName: falseoverwriteFile: truecustomMetadatamcp_imagekit_api_executeclient.files.upload()fileIdurlsizefileTypefileTypeimagenon-imagemcp_imagekit_api_executeclient.files.upload()fileIdurlsizefileTypefileTypeimagenon-image