Error on upload file "Param "fileId" is not optional" via appwrite node.js function
- 0
- 2
- Self Hosted
- Functions
- Web
- Storage
Hey everyone, I am using appwrite version 1.6.0 self-hosted with coolify. I want to switch back to the cloud env but at the moment we are in a concept phase and we are enjoying the self-hosted testing-env.
If I call createFile in my appwrite Node.js function I get this "required" parameter error.
Error: Param "fileId" is not optional.
at Client.call (/usr/local/server/src/function/node_modules/node-appwrite/lib/client.js:206:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async uploadChunk (/usr/local/server/src/function/node_modules/node-appwrite/lib/services/storage.js:383:24)
at async Storage.createFile (/usr/local/server/src/function/node_modules/node-appwrite/lib/services/storage.js:417:13)
at async Module.default (file:///usr/local/server/src/function/src/main.js:119:24)
at async execute (/usr/local/server/src/server.js:208:16)
at async action (/usr/local/server/src/server.js:225:7)
at async /usr/local/server/src/server.js:14:5
If I execute the function in the appwrite cloud env or if I start the appwrite function locally with my self-hosted endpoint everything works. createFile called from the web-js-sdk with Nuxt also works fine. I found some threads in Discord and on the appwrite forum but nothing gave me hints what to do. It breaks the moment I try to call it from the appwrite function on the self-hosted vps.
Thank you very much. Appwrite seems to be able to empower a two-man team to build some amazing things.
My Node.js appwrite function that works in appwrite cloud and appwrite self-hosted locally. I am calling OpenAi and I am trying to save the output mp3. As I said in appwrite cloud and selfhosted started locally everything works.
const mp3 = await openai.audio.speech.create({
model: 'tts-1-hd',
voice: 'nova',
input: text,
});
const audioBuffer = Buffer.from(await mp3.arrayBuffer());
log('Audio buffer generated. Buffer length:', audioBuffer.length);
// Wrap the complete audio Buffer as a finished file using InputFile.fromBuffer().
const fileName = `audio-${Date.now()}.mp3`;
const inputFile = InputFile.fromBuffer(audioBuffer, fileName);
log('InputFile created:', inputFile);
// Upload the file to Appwrite Storage.
const storage = new Storage(client);
const audioBucketId = '67a8bcee000574f3c17f';
if (!audioBucketId) {
error('Audio bucket id is not configured.');
return res.json({ error: 'Audio bucket id is not configured.' });
}
const fileResult = await storage.createFile(
audioBucketId,
ID.unique(),
inputFile
);
log('Audio file uploaded successfully:', fileResult);
```
Notes:
Because of some coolify issues (https://github.com/coollabsio/coolify/issues/3718) I am not able to call the function via the subdomain (But this should not be a issue, right?).
Ok I found the solution. In my case I was able to reproduce it: If I add https instead of the ENV var to my node.js function it works. The ENV always gives me the http URL.
new Client()
.setEndpoint('https://appwrite.example.com/v1')
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(process.env.APPWRITE_API_KEY)
);
Is this a bug or intended? For me the error message was extremely misleading and I spent over 10 hours on this issue...
Can be closed!
Recommended threads
- MongoDb Database Breaks integer[] & bigi...
I've got a table with the below column created. When I try to insert the value `[-3408048000]` into it, the dart sdk cloud function call is successful (no error...
- Appwrite Functions cold start
Hello. I'm seeing really long cold starts on Appwrite Cloud Functions and wanted to know if this is expected. My function just authenticates the user, fetches ...
- Error can not create `tablesdb` event wi...
When i'm trying to add an event with `tablesdb` i get an error message My event value: `tablesdb.mtg-decklist-dev.tables.queue_parsing.rows.*.create` Same err...