با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این راهنما نحوه استفاده از متد get() را در منبع Attachment Google Chat API برای دریافت فراداده درباره پیوست پیام توضیح میدهد. پاسخ نمونه ای از منبع Attachment است.
وقتی کاربر پیامی به برنامه شما ارسال میکند، Google Chat یک رویداد تعاملی MESSAGE را ارسال میکند. رویداد تعاملی که توسط برنامه شما دریافت میشود شامل یک بدنه درخواست است، که بار JSON نشاندهنده رویداد تعامل، از جمله هر پیوستی است. بسته به اینکه پیوست محتوای آپلود شده (فایل محلی) یا فایل ذخیره شده در Drive باشد، داده های پیوست متفاوت است. منبع Media فایلی را نشان میدهد که در چت Google آپلود شده است، مانند تصاویر، ویدیوها و اسناد. منبع Attachment نمونه ای از رسانه – یک فایل – را نشان می دهد که به یک پیام پیوست شده است. منبع Attachment شامل فراداده مربوط به پیوست است، مانند محل ذخیره آن.
اعتبار حساب سرویس ایجاد کنید . برای اجرای نمونه در این راهنما، اعتبارنامه ها را به عنوان یک فایل JSON با نام credentials.json در فهرست محلی خود ذخیره کنید.
import{createClientWithAppCredentials}from'./authentication-utils.js';// This sample shows how to get attachment metadata with app credentialasyncfunctionmain(){// Create a clientconstchatClient=createClientWithAppCredentials();// Initialize request argument(s)constrequest={// Replace SPACE_NAME, MESSAGE_NAME, and ATTACHMENT_NAME herename:'spaces/SPACE_NAME/messages/MESSAGE_NAME/attachments/ATTACHMENT_NAME',};// Make the requestconstresponse=awaitchatClient.getAttachment(request);// Handle the responseconsole.log(response);}awaitmain();
برای اجرای این نمونه، spaces/ SPACE_NAME /messages/ MESSAGE_NAME /attachments/ ATTACHMENT_NAME با نام پیوست پیام جایگزین کنید.
Chat API نمونهای از Attachment را برمیگرداند که فراداده مربوط به پیوست پیام مشخص شده را جزئیات میدهد.
تاریخ آخرین بهروزرسانی 2025-09-12 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-09-12 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThis guide explains how to retrieve metadata about a message attachment in Google Chat using the \u003ccode\u003eget()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eAttachment\u003c/code\u003e resource represents an instance of a file attached to a message and includes metadata like its location.\u003c/p\u003e\n"],["\u003cp\u003eTo get attachment metadata, you need to use the \u003ccode\u003echat.bot\u003c/code\u003e authorization scope and call the \u003ccode\u003eGetAttachment()\u003c/code\u003e method with the attachment's name.\u003c/p\u003e\n"],["\u003cp\u003ePrerequisites include a Google Workspace account, a Google Cloud project, and Node.js setup with necessary libraries and credentials.\u003c/p\u003e\n"]]],["The core actions involve retrieving metadata about a message attachment in Google Chat using the `get()` method. This requires the `chat.bot` authorization scope and calling `GetAttachment()`, providing the attachment's `name`. Before using the `get()` method, you must set up a Google Cloud project, configure the OAuth consent screen, and set up the Google Chat API. The `Attachment` resource represents the file, with metadata detailing its storage. The request triggers a response with `Attachment` details.\n"],null,[]]