Nhảy tới nội dung

saveImageToGallery

Bắt đầu hỗ trợ ở phiên bản:

  • SDK: 2.16.0
Lưu ý

Cần xin cấp quyền tại trang Quản lý ứng dụng

Lưu ảnh vào thư viện ảnh của thiết bị.

Parameters

Object object

PropertyTypeDefaultRequiredDescriptionMinimum Version
imageBase64DatastringGiá trị base64 của ảnh cần lưu.
imageUrlstringĐường dẫn của ảnh cần lưu
successfunctionCallback function khi gọi api thành công
failfunctionCallback function khi gọi api thất bại

Sample Code

import { saveImageToGallery } from "zmp-sdk/apis";

saveImageToGallery({
imageUrl: "https://sample-videos.com/img/Sample-jpg-image-50kb.jpg",
success: (res) => {
// xử lý khi gọi api thành công
},
fail: (error) => {
// xử lý khi gọi api thất bại
console.log(error);
}
});

Hoặc

import { saveImageToGallery } from "zmp-sdk/apis";

const saveImage = async () => {
try {
await saveImageToGallery({
imageUrl: "https://sample-videos.com/img/Sample-jpg-image-50kb.jpg"
});
} catch (error) {
// xử lý khi gọi api thất bại
console.log(error);
}
};

Errors

Bắt đầu hỗ trợ:

  • API phiên bản: 2.21.0
CodeMessageNote
-2004Unable to save media