For the complete documentation index, see llms.txt. This page is also available as Markdown.

File.saveBase64

函数式 API saveBase64Data也可以通过它使用相同的功能。

功能说明

将以 Base64 编码的数据按指定的文件名和 MIME 类型保存到用户设备中。可以保存图像、文本、PDF 等多种格式。 fileName中必须包含扩展名。

Toss应用 Android 5.218.0, iOS 5.216.0 可在以上使用。

类型

File.saveBase64(params: SaveBase64DataParams): Promise<void>;

Params

type SaveBase64DataParams = {
  data: string;
  fileName: string;
  mimeType: string;
};

Response

没有返回值。

示例代码

import { File } from "@apps-in-toss/web-framework";

async function handleSave() {
  try {
    await File.saveBase64({
      data: "iVBORw0KGgo...",
      fileName: "some-photo.png",
      mimeType: "image/png",
    });
  } catch (error) {
    console.error("数据保存失败:", error);
  }
}

document.querySelector("#save-file").addEventListener("click", handleSave);

这有帮助吗?