new_releases อัปเดต: ดู
บันทึกประจํารุ่นสําหรับฟีเจอร์ใหม่ๆ และการอัปเดตผลิตภัณฑ์
Method: files.create
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
อัปโหลดไฟล์เพื่อใช้ในข้อความสื่อหรือริชการ์ด
โดยตัวแทนจะระบุ URL หรือไบนารีของไฟล์และ (ไม่บังคับ) URL ของไฟล์ภาพปกที่เกี่ยวข้อง
สำคัญ: แพลตฟอร์ม RBM จะดาวน์โหลดและประมวลผลไฟล์สื่อและไฟล์ PDF จาก URL ที่ระบุไว้ก่อนที่จะส่งให้ผู้ใช้ เพื่อรักษาความเป็นส่วนตัวและความปลอดภัยของผู้ใช้ ซึ่งจะช่วยป้องกันการติดตามตัวแทนตาม URL ที่ไม่ซ้ำกัน ดังนั้นโปรดอย่าส่ง URL ที่ไม่ซ้ำกันจํานวนมาก เนื่องจากแพลตฟอร์ม RBM ไม่รองรับการดำเนินการนี้ ไม่ว่า URL จะชี้ไปยังไฟล์เดียวกันหรือไฟล์อื่น ใช้ URL เดียวกันสำหรับไฟล์ที่เหมือนกัน
แพลตฟอร์ม RBM จะแคชไฟล์ไว้ 60 วันและแสดงผลชื่อที่ไม่ซ้ำกันซึ่งคุณใช้ระบุไฟล์เมื่อส่งข้อความของตัวแทนได้
หากต้องการอัปโหลดไฟล์ไบนารี ให้ส่งคำขอ HTTP POST ไปยัง URI การอัปโหลด ละเว้นช่อง fileUrl
จากเนื้อหาคำขอ JSON และระบุไบนารีเป็นเนื้อหาคำขอ POST เช่น ใช้ Flag --upload-file
cURL กับเส้นทางไฟล์ที่มีคุณสมบัติครบถ้วนของไฟล์ไบนารี
คำขอ HTTP
- URI การอัปโหลดสำหรับคำขออัปโหลดสื่อ:
POST https://rcsbusinessmessaging.googleapis.com/upload/v1/files
- URI ข้อมูลเมตาสำหรับคำขอข้อมูลเมตาเท่านั้น
POST https://rcsbusinessmessaging.googleapis.com/v1/files
URL ใช้ไวยากรณ์การแปลง gRPC
เนื้อความของคำขอ
เนื้อความของคำขอมีข้อมูลซึ่งมีโครงสร้างดังต่อไปนี้
การแสดง JSON |
{
"fileUrl": string,
"thumbnailUrl": string,
"agentId": string
} |
ช่อง |
fileUrl |
string
ไม่บังคับ URL ของไฟล์ที่เผยแพร่ต่อสาธารณะ แพลตฟอร์ม RBM จะกำหนดประเภท MIME ของไฟล์จากช่องประเภทเนื้อหาในส่วนหัว HTTP เมื่อดึงข้อมูลไฟล์ 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 หมายเหตุ: URL ของไฟล์มีการเปลี่ยนเส้นทางได้ 1 ครั้ง URL ของไฟล์ที่เปลี่ยนเส้นทางต้องเข้าถึงได้แบบสาธารณะ URL ของไฟล์ใน CreateAgentMessageRequest ไม่รองรับการเปลี่ยนเส้นทาง
|
thumbnailUrl |
string
ไม่บังคับ URL สาธารณะของภาพปกที่สอดคล้องกับไฟล์ หากไม่ได้ตั้งค่าช่องนี้ แพลตฟอร์ม RBM จะสร้างภาพปกจากไฟล์โดยอัตโนมัติ แพลตฟอร์ม RBM จะกำหนดประเภท MIME ของไฟล์จากช่องประเภทเนื้อหาในส่วนหัว HTTP เมื่อดึงข้อมูลไฟล์ ประเภทเนื้อหารูปภาพที่รองรับ ได้แก่ image/jpeg, image/jpg, image/gif, image/png
|
agentId |
string
ต้องระบุ ตัวระบุที่ไม่ซ้ำกันของตัวแทน
|
เนื้อหาการตอบกลับ
ทรัพยากรไฟล์ที่มีชื่อที่ไม่ซ้ำกันซึ่งตัวแทนสามารถใช้เพื่อระบุไฟล์เมื่อส่งข้อความ
หากทำสำเร็จ เนื้อหาการตอบกลับจะมีข้อมูลซึ่งมีโครงสร้างดังต่อไปนี้
การแสดง JSON |
{
"name": string
} |
ช่อง |
name |
string
ชื่อที่ไม่ซ้ำกันซึ่งเซิร์ฟเวอร์กำหนดให้กับทรัพยากรไฟล์ ซึ่งตัวแทนสามารถใช้เพื่อระบุไฟล์เมื่อส่งข้อความ รูปแบบคือ "files/{uid}" โดยที่ {uid} คือรหัสที่ไม่ซ้ำกัน
|
ขอบเขตการให้สิทธิ์
ต้องใช้ขอบเขต OAuth ต่อไปนี้
https://www.googleapis.com/auth/rcsbusinessmessaging
ดูข้อมูลเพิ่มเติมได้ที่ OAuth 2.0 Overview
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[[["\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)."]]