Reputation:
I have created a script where in Google Sheet is converted to PDF and sent in an email (via Gmail API).
Please find the below syntax which is used to convert sheet to PDF
var blob=DriveApp.getFileById(<<Google Sheet ID>>).getAs('application/pdf');
what can be done to find out the size of the blob here?
Upvotes: 3
Views: 7178
Reputation: 50574
Blob has getBytes()
method, which returns a byte array.
Size of the blob(in bytes) = byte array's length
const size = blob.getBytes().length;
Upvotes: 9
Reputation: 243
If we refer to the MDN documentation (https://developer.mozilla.org/en-US/docs/Web/API/Blob/size)
Just do it like this :
var sizeInBytes = blob.size
Upvotes: 4