Hello everyone! 😊
I have a hard time figuring out the right way to send a file to an Appwrite function.
Lets say I have an image that I'd like to pass to a function, alongside a description of the file. Should I just pass it like this?
Dart: ``Uint8List pngBytes = await fetchPngBytes('');
final execution = await appWriteClientController.function.createExecution( functionId: 'upload-file, body: jsonEncode({ 'description': 'A test file', 'file': pngBytes, }));``
I also notice people encode the file to base64 first and pass that to the function. Is that a better way to pass the file?
Another thing I read is that 'Accept: multipart/form-data' should be passed to createExecution when a file is passed to a function. Is this correct?
The function side is also a bit unclear to me:
node.js:
const file = req.bodyBinary;
if (!file) {
return res.json({
success: false,
message: 'No file received'
});
} else {
return res.json({
success: true,
});
}
Is this the right way to retrieve the file in my function? 🤔
Hey, check this post with the same question: https://discord.com/channels/564160730845151244/1157683118782816328
Thanks. That question was asked a long time before binary support was added to functions in Appwrite V1.6. Is the code shown there still a best practice, or is there a better way to do it now?
I mean, it's now possible to pass a file through createExecution, right?
I'm sorry you're right, there is a better documentation with a binary file feature: https://appwrite.io/blog/post/introducing-functions-ecosystem#binary-executions
Thanks. 👍🏻👍🏻
I investigated further and I think it's not possible to upload a file through createExecution as binary, because it only takes a string as body parameter? 🤔
Recommended threads
- Cloud function deploy stucks in processi...
Been trying for the last hours to deploy my function but for whatever reason, alwasy stuck on processing!
- [SOLVED] curl error Number: 6 — function...
Hello, I invested a lot of time in this error in a fresh install of appwrite 1.8.1 and lasted until fix, this if for helping anyone that can have the same weird...
- ClientException with SocketException: Cl...
hi <@564158268319203348> i have noticed this 500 status code in my function requests, it seems its not able to connect to the internet in the function as reque...