#[Solved] Create file is listing files instead of creating the file, this inside an Appwrite function

1 messages · Page 1 of 1 (latest)

rough briar
#

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.

rough briar
#

Bump!

gilded shale
# rough briar Bump!

Probably downdrading a minor version will be better if this is actually a bug.

rough briar
rough briar
#

bump

soft spruce
#

interesting if its only happening inside a function and works fine locally 👀

can you share your function code or a minimal example? @rough briar

rough briar
#

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'] ?? '');