这通常意味着在调用 init 函数时给定的路径不存在。确保给定的路径是正确的并存在。以下是一个可能的代码示例:
const { Appwrite } = require('appwrite');
const appwrite = new Appwrite();
appwrite.setEndpoint(process.env.APPWRITE_ENDPOINT || 'http://localhost/v1') // 设置 Appwrite API 的端点
appwrite.setProject(process.env.APPWRITE_PROJECT_ID) // 设置项目 ID
appwrite.setKey(process.env.APPWRITE_API_KEY) // 设置 API 密钥
const storage = new Appwrite.Storage(appwrite);
storage.listFiles('example-folder').then((result) => {
console.log(result);
}, (err) => {
console.log('Appwrite init 函数返回错误:', err);
});
在上面的示例中,将路径 'example-folder' 传递给 storage.listFiles
函数,该路径可能不存在。如果确保给定的路径存在,将不会出现此问题。
上一篇:Appwrite环境变量被忽略
下一篇:Appwrite身份验证问题