DINHDANH Creator · Bài EM05 · Easy · 7 method file trang / upload
đủ method - tham số · trả về · lưu ý
Khác kho JSON (EM03). Easy: upload không cần login admin (chỉ chìa khóa phiên trang) - cẩn thận form công khai.
success: false.appifio_readFsFile(filePath)Việc: Đọc file trang (HTML/CSS/JS/JSON…) hoặc nhị phân (base64).
const r = await appifio_client.appifio_readFsFile('routes.json');
if (r.success) {
const routes = JSON.parse(r.data.content); // text JSON → tự parse
}
// HTML: dùng r.data.content trực tiếp (chuỗi)Trả về: { data: { content, … } }. Binary có thể kèm encoding. Chưa có path → success: false.
appifio_writeFsFile(filePath, content)Tham số: đường dẫn tương đối trong site + chuỗi nội dung (html, css, js, json…).
await appifio_client.appifio_writeFsFile('blog/detail.html', htmlString);
await appifio_client.appifio_writeFsFile('backend/functions/greetUser.js', code);Trả về: { success: true, data?: { path, size } }. Không dùng để ghi đuôi thực thi nguy hiểm (hệ thống từ chối).
appifio_deleteFsFile(filePath)await appifio_client.appifio_deleteFsFile('blog/old.html');Lưu ý: Không “xóa sạch” routes.json bằng tay để gỡ 1 URL - dùng removeRoute (EM06).
appifio_listFsFiles(subfolder?, pattern?)Tham số Easy: subfolder (mặc định ''), pattern (mặc định '').
const r = await appifio_client.appifio_listFsFiles('blog', '*.html');Khác Aura: Aura thường nhận object options { path, recursive } - Easy dùng hai chuỗi.
appifio_getFsFileInfo(filePath)const r = await appifio_client.appifio_getFsFileInfo('routes.json');
// data: path, name, size, …appifio_uploadImage(file)Tham số: đối tượng File từ input - jpg/png/gif/webp/svg… · tối đa ~10MB.
const r = await appifio_client.appifio_uploadImage(input.files[0]); const url = r.data.url; // gắnhoặc lưu vào sổ JSON
Trả về: { data: { url: "…" } }. Aura: thường cần đã đăng nhập quản trị.
appifio_uploadFile(file)Tham số: tài liệu (pdf, zip…) · tối đa ~50MB (theo giới hạn hệ thống).
const r = await appifio_client.appifio_uploadFile(input.files[0]); // r.data.url
EM06 - Route (đủ method)
Điều hướng nội bộ (cùng ngôn ngữ)
DINHDANH Creator · Loạt Easy Storage · EM05