Method: media.upload

上傳附件。如需範例,請參閱「以檔案附件上傳媒體」。使用者需要驗證

您可上傳的附件大小上限為 200 MB。系統不支援某些檔案類型。詳情請參閱「Google Chat 封鎖的檔案類型」。

HTTP 要求

  • 上傳 URI,用於媒體上傳要求:
    POST https://chat.googleapis.com/upload/v1/{parent=spaces/*}/attachments:upload
  • 中繼資料 URI,適用於僅限中繼資料的要求:
    POST https://chat.googleapis.com/v1/{parent=spaces/*}/attachments:upload

這個網址使用 gRPC 轉碼語法。

路徑參數

參數
parent

string

必要欄位。上傳附件的 Chat 聊天室資源名稱。格式化「spaces/{space}」。

要求主體

要求主體的資料會採用以下結構:

JSON 表示法
{
  "filename": string
}
欄位
filename

string

必要欄位。附件的檔案名稱,包括副檔名。

回應主體

上傳附件的回應。

如果成功,回應主體即會包含具有以下結構的資料:

JSON 表示法
{
  "attachmentDataRef": {
    object (AttachmentDataRef)
  }
}
欄位
attachmentDataRef

object (AttachmentDataRef)

所上傳附件的參照。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.messages.create
  • https://www.googleapis.com/auth/chat.messages

詳情請參閱授權指南