0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GoogleAppScriptでDriveに保存されている画像をSlackに送信

Last updated at Posted at 2019-09-12

GASを使って SlackのBotを開発しているときに、ふとインターネットに公開されていない 画像付の投稿をしたくなるときがあるのでメモ

Bot版

前提 `token発行済`

要件
GoogleDriveに保存されている画像を投稿する(インターネットに公開されていなくてOK)

file.uploadを使う
https://api.slack.com/methods/files.upload

var file = DriveApp.getFileById('GoogleDriveのファイルID');
var options = {
    "payload": {
      token: "slack access token.",
      as_user: true,
      file: file.getBlob(),
      filename: file.getName(),
      channels: channel,
  }
}
var result = UrlFetchApp.fetch("https://slack.com/api/files.upload", options);
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?