new_releases 更新:查看
版本说明,了解新功能和产品动态。
Method: files.create
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
上传文件以供在媒体或富媒体卡片消息中使用。
代理提供文件的网址或二进制文件,以及(可选)相应缩略图文件的网址。
重要提示:为了保护用户隐私和安全,RBM 平台会先从所提供的网址下载和处理媒体和 PDF 文件,然后再将其传送给用户。这可防止代理通过唯一网址进行跟踪。因此,请勿提交大量唯一网址。无论网址指向的是同一文件还是不同的文件,RBM 平台都不支持这种做法。为完全相同的文件使用相同的网址。
RBM 平台会将文件缓存 60 天,并返回一个唯一名称,您可以在发送代理消息时使用该名称来标识文件。
如需上传文件二进制文件,请向上传 URI 发出 HTTP POST 请求,从 JSON 请求正文中省略 fileUrl
字段,并将二进制文件指定为 POST 请求正文。例如,将 --upload-file
c网址 标志与二进制文件的完全限定文件路径搭配使用。
HTTP 请求
- 上传 URI,用于媒体上传请求:
POST https://rcsbusinessmessaging.googleapis.com/upload/v1/files
- 元数据 URI,用于仅涉及元数据的请求:
POST https://rcsbusinessmessaging.googleapis.com/v1/files
网址采用 gRPC 转码语法。
请求正文
请求正文中包含结构如下的数据:
JSON 表示法 |
{
"fileUrl": string,
"thumbnailUrl": string,
"agentId": string
} |
字段 |
fileUrl |
string
可选。文件的可公开访问网址。在提取文件时,RBM 平台会根据 HTTP 标头中的 content-type 字段确定文件的 MIME 类型。RBM 支持图片、音频、视频和 PDF。 支持的图片内容类型:image/jpeg、image/jpg、image/gif、image/png。 支持的音频内容类型:audio/aac、audio/mp3、audio/mpeg、audio/mpg、audio/mp4、audio/mp4-latm、audio/3gpp、application/ogg、audio/ogg。 支持的视频内容类型:video/h263、video/m4v、video/mp4、video/mpeg、video/mpeg4、video/webm。 支持的 PDF 内容类型:application/pdf。 注意:文件网址可以有 1 次重定向。重定向的文件网址必须可公开访问。CreateAgentMessageRequest 中的文件网址不支持重定向。
|
thumbnailUrl |
string
可选。与文件对应的缩略图的可公开访问网址。如果未设置此字段,RBM 平台会自动从文件中生成缩略图。在提取文件时,RBM 平台会根据 HTTP 标头中的 content-type 字段确定文件的 MIME 类型。 支持的图片内容类型:image/jpeg、image/jpg、image/gif、image/png。
|
agentId |
string
必需。代理的唯一标识符。
|
响应正文
具有唯一名称的文件资源,代理可以在发送消息时使用该名称来标识文件。
如果成功,响应正文将包含结构如下的数据:
JSON 表示法 |
{
"name": string
} |
字段 |
name |
string
服务器分配给文件资源的唯一名称,代理可在发送消息时使用该名称来标识文件。格式为“files/{uid}”,其中 {uid} 是唯一 ID。
|
授权范围
需要以下 OAuth 范围:
https://www.googleapis.com/auth/rcsbusinessmessaging
如需了解详情,请参阅 OAuth 2.0 Overview。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eThis process allows agents to upload files, including images, audio, video, and PDFs, for use in media or rich card messages, either by providing a public URL or the file's binary data.\u003c/p\u003e\n"],["\u003cp\u003eThe RBM platform handles file privacy and security by downloading and processing media files from provided URLs, preventing agent tracking via unique URLs, and caches the file for 60 days.\u003c/p\u003e\n"],["\u003cp\u003eThe file upload requires an HTTP POST request to either the upload URI \u003ccode\u003ehttps://rcsbusinessmessaging.googleapis.com/upload/v1/files\u003c/code\u003e or the metadata-only URI \u003ccode\u003ehttps://rcsbusinessmessaging.googleapis.com/v1/files\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe agent can provide a public \u003ccode\u003efileUrl\u003c/code\u003e, \u003ccode\u003ethumbnailUrl\u003c/code\u003e, and must include the \u003ccode\u003eagentId\u003c/code\u003e within the request body to upload files.\u003c/p\u003e\n"],["\u003cp\u003eUpon successful upload, the RBM platform returns a unique file name (\u003ccode\u003ename\u003c/code\u003e) that agents can use to reference the file in subsequent messages.\u003c/p\u003e\n"]]],[],null,["# Method: files.create\n\nUploads a file for use in media or rich card messages.\n\nThe agent provides the URL or binary of the file and (optionally) the URL of the corresponding thumbnail file.\n\nImportant: For user privacy and security, the RBM platform downloads and processes media and PDF files from the provided URLs before delivering them to the user. This prevents agent tracking by unique URLs. Therefore, do not submit a high volume of unique URLs. The RBM platform does not support this, whether the URLs point to the same or different files. Use the same URL for identical files.\n\nThe RBM platform caches the file for 60 days and returns a unique name that you can use to identify the file when sending agent messages.\n\nTo upload a file binary, make an HTTP POST request to the Upload URI, omit the `fileUrl` field from the JSON request body, and specify the binary as the POST request body. For example, use the `--upload-file` cURL flag with the fully qualified file path of the binary file.\n\n### HTTP request\n\n- Upload URI, for media upload requests: \n `POST https://rcsbusinessmessaging.googleapis.com/upload/v1/files`\n- Metadata URI, for metadata-only requests: \n `POST https://rcsbusinessmessaging.googleapis.com/v1/files`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation |\n|--------------------------------------------------------------------------|\n| ``` { \"fileUrl\": string, \"thumbnailUrl\": string, \"agentId\": string } ``` |\n\n| Fields ||\n|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `fileUrl` | `string` Optional. Publicly available URL of the file. The RBM platform determines the MIME type of the file from the content-type field in the HTTP headers when fetching the file. RBM supports image, audio, video, and pdf. Supported image content types: image/jpeg, image/jpg, image/gif, image/png. Supported audio content types: audio/aac, audio/mp3, audio/mpeg, audio/mpg, audio/mp4, audio/mp4-latm, audio/3gpp, application/ogg, audio/ogg. Supported video content types: video/h263, video/m4v, video/mp4, video/mpeg, video/mpeg4, video/webm. Supported pdf content types: application/pdf. Note: file URL can have 1 redirect. Redirected file URLs must be publicly accessible. Redirects are not supported for file URLs in CreateAgentMessageRequest. |\n| `thumbnailUrl` | `string` Optional. Publicly available URL of the thumbnail corresponding to the file. If this field is not set, then the RBM platform automatically generates a thumbnail from the file. The RBM platform determines the MIME type of the file from the content-type field in the HTTP headers when fetching the file. Supported image content types: image/jpeg, image/jpg, image/gif, image/png. |\n| `agentId` | `string` Required. The agent's unique identifier. |\n\n### Response body\n\nA file resource with a unique name that an agent can use to identify the file when sending messages.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|----------------------------|\n| ``` { \"name\": string } ``` |\n\n| Fields ||\n|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `name` | `string` Server-assigned unique name of the file resource, which an agent can use to identify the file when sending messages. The format is \"files/{uid}\", where {uid} is a unique ID. |\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/rcsbusinessmessaging`\n\nFor more information, see the [OAuth 2.0 Overview](/identity/protocols/OAuth2)."]]