Class Blob
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Blob
Apps Script 서비스의 데이터 교환 객체입니다.
자세한 문서
copyBlob()
이 blob의 사본을 반환합니다.
리턴
Blob
: 새 사본입니다.
getAs(contentType)
이 객체 내의 데이터를 지정된 콘텐츠 유형으로 변환된 blob으로 반환합니다. 이 메서드는 파일 이름에 적절한 확장자(예: 'myfile.pdf')를 추가합니다. 그러나 마지막 마침표 (있는 경우) 뒤에 오는 파일 이름 부분이 대체해야 할 기존 확장 프로그램이라고 가정합니다. 따라서 'ShoppingList.12.25.2014'가 'ShoppingList.12.25.pdf'가 됩니다.
전환의 일일 할당량을 보려면 Google 서비스 할당량을 참고하세요. 새로 생성된 Google Workspace 도메인에는 일시적으로 더 엄격한 할당량이 적용될 수 있습니다.
매개변수
이름 | 유형 | 설명 |
contentType | String | 변환할 MIME 유형입니다. 대부분의 blob의 경우 'application/pdf' 만 유효한 옵션입니다. BMP, GIF, JPEG 또는 PNG 형식의 이미지의 경우 'image/bmp' , 'image/gif' , 'image/jpeg' 또는 'image/png' 도 유효합니다. Google Docs 문서의 경우 'text/markdown' 도 유효합니다. |
리턴
Blob
: 데이터가 blob입니다.
getBytes()
이 blob에 저장된 데이터를 가져옵니다.
리턴
Byte[]
: 저장된 바이트입니다.
getContentType()
이 blob의 바이트 콘텐츠 유형을 가져옵니다.
리턴
String
: 이 데이터의 콘텐츠 유형입니다(알려진 경우). 또는 null
입니다.
getDataAsString()
이 blob의 데이터를 UTF-8 인코딩된 문자열로 가져옵니다.
리턴
String
: 데이터를 문자열로 나타냅니다.
getDataAsString(charset)
이 blob의 데이터를 지정된 인코딩으로 문자열로 가져옵니다.
매개변수
이름 | 유형 | 설명 |
charset | String | 이 블롭의 데이터를 문자열로 인코딩하는 데 사용할 문자 집합입니다. |
리턴
String
: 데이터를 문자열로 나타냅니다.
getName()
이 blob의 이름을 가져옵니다.
리턴
String
: 이 데이터의 이름(알려진 경우) 또는 null
입니다.
isGoogleType()
이 블롭이 Google Workspace 파일 (Sheets, Docs 등)인지 여부를 반환합니다.
리턴
Boolean
: 이 blob이 Google Workspace 파일인 경우 true
이고, 그렇지 않은 경우 false
입니다.
setBytes(data)
이 blob에 저장된 데이터를 설정합니다.
매개변수
이름 | 유형 | 설명 |
data | Byte[] | 새 데이터입니다. |
리턴
Blob
: 체이닝을 위한 blob입니다.
setContentType(contentType)
이 blob의 바이트 콘텐츠 유형을 설정합니다.
매개변수
이름 | 유형 | 설명 |
contentType | String | 새 contentType입니다. |
리턴
Blob
: 체이닝을 위한 blob입니다.
setContentTypeFromExtension()
파일 확장자를 기반으로 이 blob의 바이트 콘텐츠 유형을 설정합니다. 확장자에서 유추할 수 없는 경우 contentType은 null
입니다.
리턴
Blob
: 체이닝을 위한 blob입니다.
setDataFromString(string)
UTF-8 인코딩된 문자열에서 이 blob의 데이터를 설정합니다.
매개변수
이름 | 유형 | 설명 |
string | String | 문자열 데이터입니다. |
리턴
Blob
: 체이닝을 위한 blob입니다.
setDataFromString(string, charset)
지정된 인코딩으로 문자열에서 이 blob의 데이터를 설정합니다.
매개변수
이름 | 유형 | 설명 |
string | String | 문자열 데이터입니다. |
charset | String | 문자열을 바이트로 해석하는 데 사용할 문자 집합입니다. |
리턴
Blob
: 체이닝을 위한 blob입니다.
setName(name)
이 블롭의 이름을 설정합니다.
매개변수
이름 | 유형 | 설명 |
name | String | 새 이름입니다. |
리턴
Blob
: 체이닝을 위한 blob입니다.
지원 중단된 메서드
getAllBlobs()
지원 중단되었습니다. 이 함수는 지원 중단되었으며 새 스크립트에서 사용해서는 안 됩니다.
이 (합성일 수 있는) blob 내에 포함된 모든 blob을 가져옵니다.
리턴
Blob[]
: blob 내에 포함된 blob입니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003eA Blob is a data interchange object used for storing and manipulating binary data within Apps Script services.\u003c/p\u003e\n"],["\u003cp\u003eBlobs provide methods for setting, getting, and converting data in various formats, including bytes, strings, and specific content types.\u003c/p\u003e\n"],["\u003cp\u003eIt allows manipulation of data content, type, and name using dedicated methods.\u003c/p\u003e\n"],["\u003cp\u003eBlobs can handle Google Workspace files and offer functionalities for managing them within Apps Script.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetAllBlobs()\u003c/code\u003e method is deprecated and should not be used in new scripts.\u003c/p\u003e\n"]]],[],null,["# Class Blob\n\nBlob\n\nA data interchange object for Apps Script services. \n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------------------------------|-------------|---------------------------------------------------------------------------------------|\n| [copyBlob()](#copyBlob()) | [Blob](#) | Returns a copy of this blob. |\n| [getAs(contentType)](#getAs(String)) | [Blob](#) | Return the data inside this object as a blob converted to the specified content type. |\n| [getBytes()](#getBytes()) | `Byte[]` | Gets the data stored in this blob. |\n| [getContentType()](#getContentType()) | `String` | Gets the content type of the bytes in this blob. |\n| [getDataAsString()](#getDataAsString()) | `String` | Gets the data of this blob as a String with UTF-8 encoding. |\n| [getDataAsString(charset)](#getDataAsString(String)) | `String` | Gets the data of this blob as a string with the specified encoding. |\n| [getName()](#getName()) | `String` | Gets the name of this blob. |\n| [isGoogleType()](#isGoogleType()) | `Boolean` | Returns whether this blob is a Google Workspace file (Sheets, Docs, etc.). |\n| [setBytes(data)](#setBytes(Byte)) | [Blob](#) | Sets the data stored in this blob. |\n| [setContentType(contentType)](#setContentType(String)) | [Blob](#) | Sets the content type of the bytes in this blob. |\n| [setContentTypeFromExtension()](#setContentTypeFromExtension()) | [Blob](#) | Sets the content type of the bytes in this blob based on the file extension. |\n| [setDataFromString(string)](#setDataFromString(String)) | [Blob](#) | Sets the data of this blob from a string with UTF-8 encoding. |\n| [setDataFromString(string, charset)](#setDataFromString(String,String)) | [Blob](#) | Sets the data of this blob from a string with the specified encoding. |\n| [setName(name)](#setName(String)) | [Blob](#) | Sets the name of this blob. |\n\n### Deprecated methods\n\n| Method | Return type | Brief description |\n|---------------------------------|-------------|------------------------------------------------------------------------------|\n| [getAllBlobs()](#getAllBlobs()) | [Blob[]](#) | Gets all the blobs that are contained within this (possibly composite) blob. |\n\nDetailed documentation\n----------------------\n\n### `copy``Blob()`\n\nReturns a copy of this blob.\n\n#### Return\n\n\n[Blob](#) --- The new copy.\n\n*** ** * ** ***\n\n### `get``As(contentType)`\n\nReturn the data inside this object as a blob converted to the specified content type. This\nmethod adds the appropriate extension to the filename---for example, \"myfile.pdf\". However, it\nassumes that the part of the filename that follows the last period (if any) is an existing\nextension that should be replaced. Consequently, \"ShoppingList.12.25.2014\" becomes\n\"ShoppingList.12.25.pdf\".\n\nTo view the daily quotas for conversions, see [Quotas for Google\nServices](https://developers.google.com/apps-script/guides/services/quotas). Newly created Google Workspace domains might be temporarily subject to stricter\nquotas.\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `content``Type` | `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. For a Google Docs document, `'text/markdown'` is also valid. |\n\n#### Return\n\n\n[Blob](#) --- The data as a blob.\n\n*** ** * ** ***\n\n### `get``Bytes()`\n\nGets the data stored in this blob.\n\n#### Return\n\n\n`Byte[]` --- The stored bytes.\n\n*** ** * ** ***\n\n### `get``Content``Type()`\n\nGets the content type of the bytes in this blob.\n\n#### Return\n\n\n`String` --- The content type of this data, if known, or `null`.\n\n*** ** * ** ***\n\n### `get``Data``As``String()`\n\nGets the data of this blob as a String with UTF-8 encoding.\n\n#### Return\n\n\n`String` --- The data as a string.\n\n*** ** * ** ***\n\n### `get``Data``As``String(charset)`\n\nGets the data of this blob as a string with the specified encoding.\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------|----------|-------------------------------------------------------------------|\n| `charset` | `String` | The charset to use in encoding the data in this blob as a string. |\n\n#### Return\n\n\n`String` --- The data as a string.\n\n*** ** * ** ***\n\n### `get``Name()`\n\nGets the name of this blob.\n\n#### Return\n\n\n`String` --- The name of this data, if known, or `null`.\n\n*** ** * ** ***\n\n### `is``Google``Type()`\n\nReturns whether this blob is a Google Workspace file (Sheets, Docs, etc.).\n\n#### Return\n\n\n`Boolean` --- `true` if this blob is a Google Workspace file; `false` if not.\n\n*** ** * ** ***\n\n### `set``Bytes(data)`\n\nSets the data stored in this blob.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|---------------|\n| `data` | `Byte[]` | The new data. |\n\n#### Return\n\n\n[Blob](#) --- This blob, for chaining.\n\n*** ** * ** ***\n\n### `set``Content``Type(contentType)`\n\nSets the content type of the bytes in this blob.\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------------|----------|----------------------|\n| `content``Type` | `String` | The new contentType. |\n\n#### Return\n\n\n[Blob](#) --- This blob, for chaining.\n\n*** ** * ** ***\n\n### `set``Content``Type``From``Extension()`\n\nSets the content type of the bytes in this blob based on the file extension. The contentType is\n`null` if it cannot be guessed from its extension.\n\n#### Return\n\n\n[Blob](#) --- This blob, for chaining.\n\n*** ** * ** ***\n\n### `set``Data``From``String(string)`\n\nSets the data of this blob from a string with UTF-8 encoding.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------|----------|------------------|\n| `string` | `String` | The string data. |\n\n#### Return\n\n\n[Blob](#) --- This blob, for chaining.\n\n*** ** * ** ***\n\n### `set``Data``From``String(string, charset)`\n\nSets the data of this blob from a string with the specified encoding.\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------|----------|---------------------------------------------------------|\n| `string` | `String` | The string data. |\n| `charset` | `String` | The charset to use in interpreting the string as bytes. |\n\n#### Return\n\n\n[Blob](#) --- This blob, for chaining.\n\n*** ** * ** ***\n\n### `set``Name(name)`\n\nSets the name of this blob.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|---------------|\n| `name` | `String` | The new name. |\n\n#### Return\n\n\n[Blob](#) --- This blob, for chaining.\n\nDeprecated methods\n------------------\n\n### `get``All``Blobs()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nGets all the blobs that are contained within this (possibly composite) blob.\n\n#### Return\n\n\n[Blob[]](#) --- The blobs contained within the blob."]]