Method: media.upload
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-25 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-25 (שעון UTC)."],[[["\u003cp\u003eUploads an attachment to a Google Chat space, supporting files up to 200 MB.\u003c/p\u003e\n"],["\u003cp\u003eUses an HTTP POST request to a specific URI with the space ID as a path parameter.\u003c/p\u003e\n"],["\u003cp\u003eRequires a JSON request body specifying the filename of the attachment.\u003c/p\u003e\n"],["\u003cp\u003eThe response includes an \u003ccode\u003eattachmentDataRef\u003c/code\u003e object referencing the uploaded file.\u003c/p\u003e\n"],["\u003cp\u003eRequires specific authorization scopes for user authentication.\u003c/p\u003e\n"]]],["This document details the process for uploading attachments in Google Chat, limited to 200MB with certain file types restricted. The HTTP request uses `POST` to `https://chat.googleapis.com/upload/v1/{parent=spaces/*}/attachments:upload`, requiring a `parent` path parameter specifying the target space. The request body must include the attachment's `filename`. A successful upload returns an `attachmentDataRef` object. Authorization requires specific OAuth scopes like `chat.import`, `chat.messages.create`, or `chat.messages`.\n"],null,["# Method: media.upload\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n - [JSON representation](#body.request_body.SCHEMA_REPRESENTATION)\n- [Response body](#body.response_body)\n - [JSON representation](#body.UploadAttachmentResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n\nUploads an attachment. For an example, see [Upload media as a file attachment](https://developers.google.com/workspace/chat/upload-media-attachments).\n\nRequires user [authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) with one of the following [authorization scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):\n\n- `https://www.googleapis.com/auth/chat.messages.create`\n- `https://www.googleapis.com/auth/chat.messages`\n- `https://www.googleapis.com/auth/chat.import` (import mode spaces only)\n\nYou can upload attachments up to 200 MB. Certain file types aren't supported. For details, see [File types blocked by Google Chat](https://support.google.com/chat/answer/7651457?&co=GENIE.Platform%3DDesktop#File%20types%20blocked%20in%20Google%20Chat).\n\n### HTTP request\n\n- Upload URI, for media upload requests: \n `POST https://chat.googleapis.com/upload/v1/{parent=spaces/*}/attachments:upload`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|------------------------------------------------------------------------------------------------------------------|\n| `parent` | `string` Required. Resource name of the Chat space in which the attachment is uploaded. Format \"spaces/{space}\". |\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation |\n|--------------------------------|\n| ``` { \"filename\": string } ``` |\n\n| Fields ||\n|------------|----------------------------------------------------------------------------------|\n| `filename` | `string` Required. The filename of the attachment, including the file extension. |\n\n### Response body\n\nResponse of uploading an attachment.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|----------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"attachmentDataRef\": { object (/workspace/chat/api/reference/rest/v1/spaces.messages.attachments#Attachment.AttachmentDataRef) } } ``` |\n\n| Fields ||\n|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `attachmentDataRef` | `object (`[AttachmentDataRef](/workspace/chat/api/reference/rest/v1/spaces.messages.attachments#Attachment.AttachmentDataRef)`)` Reference to the uploaded attachment. |\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/chat.import`\n- `https://www.googleapis.com/auth/chat.messages.create`\n- `https://www.googleapis.com/auth/chat.messages`\n\nFor more information, see the [Authorization guide](/workspace/chat/authenticate-authorize)."]]