A data interchange object for Apps Script services.
Methods
Method | Return type | Brief description |
---|---|---|
copyBlob() | Blob | Returns a copy of this blob. |
getAs(contentType) | CompositeBlob | Return the data inside this object as a Blob converted to the specified content type. |
getBytes() | Byte[] | Gets the data stored in this blob. |
getContentType() | String | Gets the content type of the bytes in this blob. |
getDataAsString() | String | Gets the data of this blog as a String with utf-8 encoding. |
getDataAsString(charset) | String | Gets the data of this blog as a String with the specified encoding. |
getName() | String | Gets the name of this blob. |
isGoogleType() | Boolean | Returns whether this blob is wrapping a Google Doc type (Sheets, Docs, etc.). |
setBytes(data) | Blob | Sets the data stored in this blob. |
setContentType(contentType) | Blob | Sets the content type of the bytes in this blob. |
setContentTypeFromExtension() | Blob | Sets the content type of the bytes in this blob based on the file extension. |
setDataFromString(string) | Blob | Sets the data of this blob from a String with utf-8 encoding. |
setDataFromString(string, charset) | Blob | Sets the data of this blob from a String with the specified encoding. |
setName(name) | Blob | Sets the name of this blob. |
Detailed documentation
getAs(contentType)
Return the data inside this object as a Blob converted to the specified content type.
Parameters
Name | Type | Description |
---|---|---|
contentType | String | the MIME type to convert to. For most blobs,
'application/pdf' is the only valid option. For images in BMP, GIF, JPEG,
or PNG format, any of 'image/bmp' , 'image/gif' ,
'image/jpeg' , or 'image/png' are also valid. |
Return
CompositeBlob
— the data as a blob
getBytes()
Gets the data stored in this blob.
Return
Byte[]
— the stored bytes
getContentType()
Gets the content type of the bytes in this blob.
Return
String
— the content type of this data, if known, or null
getDataAsString()
Gets the data of this blog as a String with utf-8 encoding.
Return
String
— the data as a string
getDataAsString(charset)
Gets the data of this blog as a String with the specified encoding.
Parameters
Name | Type | Description |
---|---|---|
charset | String | the charset to use in encoding the data in this blob as a string |
Return
String
— the data as a string
getName()
Gets the name of this blob.
Return
String
— the name of this data, if known, or null
isGoogleType()
Returns whether this blob is wrapping a Google Doc type (Sheets, Docs, etc.).
Return
Boolean
— true if this Blob is wrapping a Google type
setBytes(data)
Sets the data stored in this blob.
Parameters
Name | Type | Description |
---|---|---|
data | Byte[] | the new data |
Return
Blob
— this BlobApi for chaining
setContentType(contentType)
Sets the content type of the bytes in this blob.
Parameters
Name | Type | Description |
---|---|---|
contentType | String | the new contentType |
Return
Blob
— this BlobApi for chaining
setContentTypeFromExtension()
Sets the content type of the bytes in this blob based on the file extension. The contentType will be null if it cannot be guessed from its extension.
Return
Blob
— this BlobApi for chaining
setDataFromString(string)
Sets the data of this blob from a String with utf-8 encoding.
Parameters
Name | Type | Description |
---|---|---|
string | String | the string data |
Return
Blob
— this BlobApi for chaining
setDataFromString(string, charset)
Sets the data of this blob from a String with the specified encoding.
Parameters
Name | Type | Description |
---|---|---|
string | String | the string data |
charset | String | the charset to use in interpreting the string as bytes |
Return
Blob
— this BlobApi for chaining
setName(name)
Sets the name of this blob.
Parameters
Name | Type | Description |
---|---|---|
name | String | the new name |
Return
Blob
— this BlobApi for chaining