LoginSignup
4
3

More than 5 years have passed since last update.

GASでGoogleDriveにあるテキスト以外のファイルを更新する

Last updated at Posted at 2018-11-29

はじめに

DriveAppクラスでidを維持したままファイルを更新するメソッドがなくて(テキストはsetContent()がある)、Advanced Drive Serviceを使おうとしたらハマったので置いておきます

方法

リソース→Googleの拡張サービスよりDrive APIをONにしておく


//画像を更新する場合
function updateImageFile(title,targetId,blob) {
  var body = {
    title: title,
    mimeType: 'image/png'
  };

  file = Drive.Files.update(body,targetId, blob);

  Logger.log('ID: %s, File size (bytes): %s', file.id, file.fileSize);
}
4
3
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
4
3