Method: media.download
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eDownloads uploaded media, excluding Google Drive files, using the \u003ccode\u003e/v1/media/{+name}?alt=media\u003c/code\u003e URI.\u003c/p\u003e\n"],["\u003cp\u003eTo download, use a GET request specifying the media's resource name in the URL path.\u003c/p\u003e\n"],["\u003cp\u003eThe response provides the file content as bytes, supporting partial downloads via the \u003ccode\u003eRange\u003c/code\u003e header.\u003c/p\u003e\n"],["\u003cp\u003eAuthorization requires a Chat scope like \u003ccode\u003echat.bot\u003c/code\u003e, \u003ccode\u003echat.messages\u003c/code\u003e, or \u003ccode\u003echat.messages.readonly\u003c/code\u003e.\u003c/p\u003e\n"]]],["The core functionality involves downloading uploaded media via a `GET` HTTP request to `/v1/media/{resourceName}`. The `resourceName` path parameter specifies the media to download. The request body must be empty. A successful response returns the file content as bytes. Partial downloads are supported using the `Range` header. Access requires specific OAuth scopes: `chat.bot`, `chat.messages`, or `chat.messages.readonly`. Google Drive files utilize a separate files.export method.\n"],null,["- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.Media.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n\nDownloads uploaded media, but not Google Drive files. Download is supported on the URI `/v1/media/{+name}?alt=media`. To export bytes from a Google Drive file, see the [files.export](https://developers.google.com/drive/api/reference/rest/v3/files/export) method in Google Drive.\n\nHTTP request\n\n`GET https://chat.googleapis.com/v1/media/{resourceName=**}`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\nPath parameters\n\n| Parameters ||\n|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `resourceName` | `string` Name of the media that you are downloading. For more information, see [spaces.messages.attachments.attachmentDataRef](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages.attachments#Attachment.AttachmentDataRef). |\n\nRequest body\n\nThe request body must be empty.\n\nResponse body\n\nIf successful, this method returns the file content as bytes.\n\nTo download only part of a file, use the `Range` header with a [byte range](https://www.rfc-editor.org/rfc/rfc9110.html#name-byte-ranges). For example: `Range: bytes=500-999`.\n\nAuthorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/chat.bot`\n- `https://www.googleapis.com/auth/chat.messages`\n- `https://www.googleapis.com/auth/chat.messages.readonly`\n\nFor more information, see the [Authorization guide](/workspace/chat/authenticate-authorize)."]]