GAS googleドライブで使用できる容量の上限を取得する

GAS googleドライブで使用できる容量の上限を取得する

GAS(Google Apps Script)で、googleドライブで使用できる容量の上限を取得する手順を記述してます。「getStorageLimit」で可能です。戻り値は、バイト単位で返ってきます。

環境

  • OS windows11 home
  • ブラウザ chrome 107.0.5304.122

使用できる容量の上限を取得

使用できる容量の上限を取得するには、「getStorageLimit」を使用します。

DriveApp.getStorageLimit()

実際に、取得してみます。

function myFunction() {

  const storageLimit = DriveApp.getStorageLimit();

  console.log(storageLimit + 'B'); //Byte単位
  console.log(storageLimit / 1024  + 'KB'); //KB単位
  console.log(storageLimit / ( 1024 ** 2 )  + 'MB'); //MB単位
  console.log(storageLimit / ( 1024 ** 3 ) + 'GB'); //GB単位

}

実行結果を見ると取得されていることが確認できます。