Reputation: 13
var data = Utilities.newBlob("THis is blob data", MimeType.PLAIN_TEXT, 'test.txt');
if ( ?? ) then Logger.log('yes, this is blob') ;
How to detect data is blob? (not object)
instanceof Blob
// or
instanceof BlobSource
Result: ReferenceError: Blob
or BlobSource
is not defined
instanceof GoogleAppsScript.Base.Blob;
// ReferenceError: `GoogleAppsScript` is not defined
typeof data
// result: object
Object.prototype.toString.call(data);
// result: [object Object]
Upvotes: 1
Views: 579
Reputation:
Try using duck typing:
if (typeof data.copyBlob === 'function')
{
// it's probably a blob
console.log('yep');
}
Reference: Class Blob
Upvotes: 5