Interface BlobSource
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
BlobSource
Giao diện cho các đối tượng có thể xuất dữ liệu dưới dạng Blob
.
Triển khai lớp
Tên | Mô tả ngắn |
Blob | Đối tượng trao đổi dữ liệu cho các dịch vụ Apps Script. |
Chart | Một đối tượng Biểu đồ có thể được chuyển đổi thành hình ảnh tĩnh. |
Document | Một tài liệu, chứa một hoặc nhiều đối tượng Tab , mỗi đối tượng chứa văn bản đa dạng thức và các phần tử như bảng và danh sách. |
EmbeddedChart | Biểu thị một biểu đồ đã được nhúng vào bảng tính. |
File | Một tệp trong Google Drive. |
GmailAttachment | Tệp đính kèm trong Gmail. |
HTTPResponse | Lớp này cho phép người dùng truy cập vào thông tin cụ thể về các phản hồi HTTP. |
HtmlOutput | Một đối tượng HtmlOutput có thể được phân phát từ một tập lệnh. |
Image | PageElement đại diện cho một hình ảnh. |
InlineImage | Một phần tử đại diện cho hình ảnh được nhúng. |
JdbcBlob | Blob JDBC. |
JdbcClob | Clob JDBC. |
PictureFill | Một lớp phủ hiển thị hình ảnh được kéo giãn theo kích thước của vùng chứa. |
PositionedImage | Hình ảnh vị trí cố định được neo vào Paragraph . |
Spreadsheet | Truy cập và sửa đổi tệp Google Trang tính. |
StaticMap | Cho phép tạo và trang trí hình ảnh bản đồ tĩnh. |
Phương thức
Phương thức | Loại dữ liệu trả về | Mô tả ngắn |
getAs(contentType) | Blob | Trả về dữ liệu bên trong đối tượng này dưới dạng một blob được chuyển đổi thành loại nội dung đã chỉ định. |
getBlob() | Blob | Trả về dữ liệu bên trong đối tượng này dưới dạng blob. |
Tài liệu chi tiết
getAs(contentType)
Trả về dữ liệu bên trong đối tượng này dưới dạng một blob được chuyển đổi thành loại nội dung đã chỉ định. Phương thức này thêm đuôi tệp thích hợp vào tên tệp, ví dụ: "myfile.pdf". Tuy nhiên, hàm này giả định rằng phần tên tệp theo sau dấu chấm cuối cùng (nếu có) là một đuôi tệp hiện có cần được thay thế. Do đó, "ShoppingList.12.25.2014" sẽ trở thành "ShoppingList.12.25.pdf".
Để xem hạn mức hằng ngày cho lượt chuyển đổi, hãy xem bài viết Hạn mức cho Dịch vụ của Google. Các miền Google Workspace mới tạo có thể tạm thời phải tuân theo hạn mức nghiêm ngặt hơn.
Tham số
Tên | Loại | Mô tả |
contentType | String | Loại MIME cần chuyển đổi sang. Đối với hầu hết các blob, 'application/pdf' là tuỳ chọn hợp lệ duy nhất. Đối với hình ảnh ở định dạng BMP, GIF, JPEG hoặc PNG, bất kỳ 'image/bmp' , 'image/gif' , 'image/jpeg' hoặc 'image/png' nào cũng đều hợp lệ. Đối với tài liệu Google Tài liệu, 'text/markdown' cũng hợp lệ. |
Cầu thủ trả bóng
Blob
– Dữ liệu dưới dạng blob.
getBlob()
Trả về dữ liệu bên trong đối tượng này dưới dạng blob.
Cầu thủ trả bóng
Blob
– Dữ liệu dưới dạng blob.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eBlobSource\u003c/code\u003e is an interface allowing objects to export their data as a Blob.\u003c/p\u003e\n"],["\u003cp\u003eIt offers two primary methods: \u003ccode\u003egetAs()\u003c/code\u003e to retrieve data as a Blob with a specific content type and \u003ccode\u003egetBlob()\u003c/code\u003e for getting data as a raw Blob.\u003c/p\u003e\n"],["\u003cp\u003eVarious Apps Script objects, including Documents, Spreadsheets, and Images, implement this interface.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetAs()\u003c/code\u003e can convert data to formats like PDF, common image types, and Markdown for Google Docs, but is subject to usage quotas.\u003c/p\u003e\n"]]],[],null,["# Interface BlobSource\n\nBlobSource\n\nInterface for objects that can export their data as a [Blob](/apps-script/reference/base/blob).\n\n### Implementing classes\n\n| Name | Brief description |\n|------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Blob](/apps-script/reference/base/blob) | A data interchange object for Apps Script services. |\n| [Chart](../charts/chart.html) | A Chart object, which can be converted to a static image. |\n| [Document](../document/document.html) | A document, containing one or more [Tab](../document/tab.html) objects, each of which contains rich text and elements such as tables and lists. |\n| [EmbeddedChart](../spreadsheet/embedded-chart.html) | Represents a chart that has been embedded into a spreadsheet. |\n| [File](../drive/file.html) | A file in Google Drive. |\n| [GmailAttachment](../gmail/gmail-attachment.html) | An attachment from Gmail. |\n| [HTTPResponse](../url-fetch/http-response.html) | This class allows users to access specific information on HTTP responses. |\n| [HtmlOutput](../html/html-output.html) | An `Html``Output` object that can be served from a script. |\n| [Image](../slides/image.html) | A [PageElement](../slides/page-element.html) representing an image. |\n| [InlineImage](../document/inline-image.html) | An element representing an embedded image. |\n| [JdbcBlob](../jdbc/jdbc-blob.html) | A JDBC `Blob`. |\n| [JdbcClob](../jdbc/jdbc-clob.html) | A JDBC `Clob`. |\n| [PictureFill](../slides/picture-fill.html) | A fill that renders an image that's stretched to the dimensions of its container. |\n| [PositionedImage](../document/positioned-image.html) | Fixed position image anchored to a [Paragraph](../document/paragraph.html). |\n| [Spreadsheet](../spreadsheet/spreadsheet.html) | Access and modify Google Sheets files. |\n| [StaticMap](../maps/static-map.html) | Allows for the creation and decoration of static map images. |\n\n### Methods\n\n| Method | Return type | Brief description |\n|--------------------------------------|------------------------------------------|---------------------------------------------------------------------------------------|\n| [getAs(contentType)](#getAs(String)) | [Blob](/apps-script/reference/base/blob) | Return the data inside this object as a blob converted to the specified content type. |\n| [getBlob()](#getBlob()) | [Blob](/apps-script/reference/base/blob) | Return the data inside this object as a blob. |\n\nDetailed documentation\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](/apps-script/reference/base/blob) --- The data as a blob.\n\n*** ** * ** ***\n\n### `get``Blob()`\n\nReturn the data inside this object as a blob.\n\n#### Return\n\n\n[Blob](/apps-script/reference/base/blob) --- The data as a blob."]]