-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Open
Description
Looking at the example from doc, I created a new project with .env containing my api key and loaded using dotenv, and trying different variations to write a file: (puter.fs.write('hello.txt'...), puter.fs.write('./hello.txt'..), puter.fs.write('~/hello.txt'..), puter.fs.write('<FULL_PATH>/hello.txt'..)... it always ends with error, here is my last attempt:
import { init } from "@heyputer/puter.js/src/init.cjs";
import "dotenv/config";
const puter = init(process.env.puterAuthToken); // uses your auth token
const username = await puter.getUser().then(info => info.username)
console.log(`Welcome back :${username}!`);
const dirPath = `/${username}/Public`;
// Create a file
puter.fs
.write(`${dirPath}/hello.txt`, 'Hello, world!')
.then(() => {
console.log("File written successfully");
})
.catch((error) => {
console.log("Error writing file:", error);
});Here is the current log:
Error writing file: {
code: 'forbidden',
'$': 'heyputer:api/APIError',
message: 'Permission denied.',
status: 403
}
This error is root cause of this issue.
I don't know if the @heyputer/puter.js is supposed to have the same API for the client library since it requires to be initialized with init, or if we can you make it loads puterAuthToken directly from the env var ?
Metadata
Metadata
Assignees
Labels
No labels