I am trying to upload file to appwrite storage, but it's not working, I tried with the 2 following codes:
Code1: using InputFile:
const { Client, Storage, InputFile } = require('node-appwrite');
const filePath = './path/to/your/file.txt'; // Local file path
const fileName = 'uploaded-file.txt'; // Name to assign to the file in Appwrite
const file = InputFile.fromPath(filePath, fileName);
const fileUploadResponse = await storage.createFile(
process.env.APPWRITE_STORAGE_QRCODES,
'unique()',
file
);
Code2: using createReadStream:
const { Client, Storage, InputFile } = require('node-appwrite');
const file = fs.createReadStream(qrCodeFilePath);
const fileUploadResponse = await storage.createFile(
process.env.APPWRITE_STORAGE_QRCODES,
'unique()',
file
);
related issue: https://appwrite.io/threads/1250841985699287143
Can I ask what error messages you are receiving? Also, have you taken a look at the storage api reference docs for createFile
? https://appwrite.io/docs/references/cloud/server-nodejs/storage#createFile
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...