Skip to main content
本页的每个方法都位于 app.files 上:

列出目录中的文件

app.files.list(path?) 返回一个目录的条目。路径默认为 "/"

读取文件

app.files.read(path) 返回一个包含文件内容的 Node.js Buffer,当文件不存在时返回 undefined
读取过大的文件会失败,报错代码为 FILE_TOO_LARGE(413)。

创建或覆盖文件

app.files.create(file, fileName, path?)path/fileName 处写入一个文件。路径默认为 "/"
签名在 v4 中发生了变化。之前的版本接受 create(content, fullPath) —— v4 要求 create(content, fileName, path)

编辑文件

app.files.edit(file, path) 覆盖 path 处已存在文件的内容。

移动或重命名文件

app.files.move(path, newPath) 移动或重命名文件或目录。

删除文件或目录

app.files.delete(path) 删除一个文件或整个目录。