1
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.

【GAS】ドライブ、Gmail、フォト それぞれの使用容量を調べる

Last updated at Posted at 2020-09-16

目的

Gmail の使用容量を取得して、一定の割合を超えたらメールを飛ばす仕組みを作りたかった。

Gmail の使用容量は、ドライブ、フォトと共有しているとのことで、それぞれの使用容量を調べます。

手順

1. Drive API を有効にする

リソース > Google の拡張サービス を選択。

Google の拡張サービス.PNG

Drive API を有効にする

drive_api.PNG

2. 使用容量を調べる

.js
function myFunc() {
  var about = Drive.About.get();
  var quota = about.quotaBytesByService;
  Logger.log(quota);
}

// ↓ 結果 ↓
// [
//   {bytesUsed=19309750, serviceName=DRIVE},
//   {bytesUsed=2000998011, serviceName=GMAIL},
//   {bytesUsed=0, serviceName=PHOTOS}
// ]
  • quota.serviceName = サービスの名前
  • quota.bytesUsed = 使用容量(バイト)

参考

1
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
1
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?