Chuyển tới nội dung chính

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

  • SDK: 2.51.0
  • Android: 25.11.02
  • IOS: 25.12.02

Lấy thông tin local file. File có thể ở dạng tạm hoặc đã được lưu bền (local cache hoặc local data).

Parameters

Object object

PropertyTypeDefaultRequiredDescriptionMinimum Version
filePathstringtrueĐường dẫn tới file trong folder tạm hoặc đã lưu cục bộ
digestAlgorithmstringmd5Thuật toán băm để lấy file summary, hỗ trợ các loại sau:
  • md5
  • sha1
successfunctionCallback function khi gọi api thành công
failfunctionCallback function khi gọi api thất bại

Return Values

Promise <Object data>

PropertyTypeDescriptionMinimum Version
sizenumberKích thước file (byte size)
digeststringGiá trị băm được tính dựa trên thông số của file (gồm size và tên của file)
typestringKiểu file (Vd: image/jpeg, video/mp4)

Sample Code

import { LFSStorage } from 'zmp-sdk/apis';

LFSStorage.getFileInfo({
filePath: "[Đường dẫn tới file]",
digestAlgorithm: "md5",
success: (data) => {
// xử lý khi gọi api thành công
const { size, digest, type } = data;
},
fail: (error) => {
// xử lý khi gọi api thất bại
console.log(error);
},
});

// hoặc

import { LFSStorage } from 'zmp-sdk/apis';

const getFileInfo = async () => {
try {
const { size, digest, type } = await LFSStorage.getFileInfo({
filePath: "[Đường dẫn tới file]",
digestAlgorithm: "md5",
});
} catch (error) {
// xử lý khi gọi api thất bại
console.log(error);
}
};

Errors

CodeMessageNote
-302File cannot be found. Please check your param again.
miniapp-logo

Khám phá