Nhảy tới nội dung

my.getSavedFileList

getSavedFileList

my.getSavedFileList là API dùng để lấy thông tin tất cả các tập tin được lưu cục bộ của Tini App gọi API này.

Quét mã để trải nghiệm

Xem code mẫu trên Tini Studio

Demo

Trải nghiệm thử với trình giả lập bên dưới

API Params

Thuộc tínhKiểu dữ liệuBắt buộcMô tả
filePathStringĐường dẫn tới local file
successFunctionCallback function khi lấy thông tin tất cả tập tin thành công
failFunctionCallback function khi lấy thông tin tất cả tập tin thất bại
completeFunctionCallback function khi việc gọi API kết thúc bất kể thành công hay thất bại.

Callback success function payload

Thuộc tínhKiểu dữ liệuMô tả
fileListArray of ObjectsArray chứa thông tin tất cả tập tin được lưu cục bộ

fileList payload

Thuộc tínhKiểu dữ liệuMô tả
sizeNumberDung lượng của tập tin
createTimeStringNgày giờ tập tin được tạo ra
filePathStringĐường dẫn của tập tin

Sample Code

<view>
<block-header title="Usage" description="File system" />
<view class="block-content">
<image src="{{tempFilePath}}" />
<button class="button-full" onTap="onChooseImage">Choose Image</button>
</view>
<view class="block-content">
<button class="button-full" onTap="onSaveFile">Save Image</button>
<button class="button-full" onTap="onGetFileInfo">Get File Info</button>
<button class="button-full" onTap="onGetSavedFileInfo">Get Saved File Info</button>
<button class="button-full" onTap="onGetSavedFileList">Get Saved File List</button>
<button class="button-full" onTap="onRemoveSavedFile">Remove Save File</button>
</view>
</view>
Page({
data: {
tempFilePath: undefined,
savedFilePath: undefined
},
onChooseImage() {
my.chooseImage({
count: 1,
success: (res) => {
console.log(res);
this.setData({
tempFilePath: res.filePaths[0]
});
},
fail: (e) => {
console.log(e);
}
});
},
onGetSavedFileList() {
my.getSavedFileList({
success: (res) => {
my.alert({
title: 'Saved File List',
content: JSON.stringify(res)
});
console.log(JSON.stringify(res));
},
fail: (e) => {
console.log(e);
}
});
}
});