[Solved] Create file is listing files instead of creating the file, this inside an Appwrite function
- 0
- Resolved
- 2
- Self Hosted
- Functions
- Storage
This is a bit strange but, I cannot create files from within a funcion. I have tested with latest SDKs versions of node and python, both instead of creating the file, return the list of files that are stored on the bucket.
result = await storage.createFile({
bucketId: OUTPUT_BUCKET_ID,
fileId: outputFileId,
file: InputFile.fromPath(tempPath, "certificate.pdf")
});
log(`createFile: ${JSON.stringify(result)}`);
createFile: {"total":3,"files":[{"$id":"69262f31001d4ecdf886","bucketId":"b_internal","$createdAt":"2025-11-25T22:35:29.899+00:00","$updatedAt":"2025-11-25T22:35:29.899+00:00","$permissions":["read(\"user:67086926000a44243115\")","update(\"user:67086926000a44243115\")","delete(\"user:67086926000a44243115\")"],"name":"university.png","signature":"561b1e77208ff23b5557b89ff8ee8ae5","mimeType":"image/png","sizeOriginal":27818,"chunksTotal":1,"chunksUploaded":1},{"$id":"69262f3500361d4be8dd","bucketId":"b_internal","$createdAt":"2025-11-25T22:35:34.283+00:00","$updatedAt":"2025-11-25T22:35:34.283+00:00","$permissions":["read(\"user:67086926000a44243115\")","update(\"user:67086926000a44243115\")","delete(\"user:67086926000a44243115\")"],"name":"signature.png","signature":"e36241b01aaa5cf646fc84cdee2c7307","mimeType":"image/png","sizeOriginal":10652,"chunksTotal":1,"chunksUploaded":1},{"$id":"6926310a0011858de642","bucketId":"b_internal","$createdAt":"2025-11-25T22:43:22.732+00:00","$updatedAt":"2025-11-25T22:43:22.732+00:00","$permissions":["read(\"user:67086926000a44243115\")","update(\"user:67086926000a44243115\")","delete(\"user:67086926000a44243115\")"],"name":"logo.png","signature":"64182af861a6f03318517c9de291613b","mimeType":"image/png","sizeOriginal":26408,"chunksTotal":1,"chunksUploaded":1}]}
Any help will be really appreciated.
Bump!
Probably downdrading a minor version will be better if this is actually a bug.
Thanks for your answer, but its weird, I have tested on my local machine and it worked, but within the appwrite functions it just does like I said. Pretty weird.
bump
interesting if its only happening inside a function and works fine locally π
can you share your function code or a minimal example? <@679147141926617108>
Seems like now is not only storage, I have created a new Table and look at this:
The function:
import { Client, TablesDB, ID, Permission, Role } from 'node-appwrite';
export default async ({ req, res, log, error }) => {
const client = new Client()
.setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT)
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(req.headers['x-appwrite-key'] ?? '');
const tablesDB = new TablesDB(client);
try {
let res = await tablesDB.createRow({
databaseId: 'db_master',
tableId: 'wallet_transactions',
rowId: ID.unique(),
data: {
"userId": '123123',
"type": 'credit',
"amount": '10',
"description": `Hello!`,
"translationId": null,
"referralUserId": '123123'
},
permissions: [
Permission.read(Role.label('admin')),
Permission.update(Role.label('admin')),
Permission.delete(Role.label('admin'))
]
}
);
log("Response: ", res);
} catch (err) {
error("Err: " + err.message);
}
return res.json({
motto: "Build like a team of hundreds_",
learn: "https://appwrite.io/docs",
connect: "https://appwrite.io/discord",
getInspired: "https://builtwith.appwrite.io",
});
};
The log:
Response: {"total":0,"rows":[]}
Im using "node-appwrite": "^20.2.1"
And runtime node-22
I did ask to gemini and it gives me the answer:
Since I am behind nginx seems like sometimes the SDK gets bugged, so forcing the endpoint to use https fixes the issue:
const client = new Client()
.setEndpoint("https://<your_appwrite_ip_or_domain>/v1")
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(req.headers['x-appwrite-key'] ?? '');
[Solved] Create file is listing files instead of creating the file, this inside an Appwrite function
Recommended threads
- Accessing Database via Console
Hi everyone, I am running a self-hosted Appwrite v1.9.0 instance. When I click on one particular database in the Console, a loading indicator appears at the top...
- Apple OAuth2 settings auto-disable every...
Hello, I'm on Appwrite 1.8.1 at the moment. I'm using on prod Apple Oauth and it keeps disabling itself every night. I don't know where to look for the solutio...
- Sites settings shows ALL build runtimes
When looking at the build runtimes of site to update from node22 to node24, i saw that unlike the Functions the Sites shows ALL build runtimes, even non-install...