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
- Session not found. Please run appwrite l...
I have encounter an issue with appwrite CLI They asking for a login session but in the doc, it’s mention that only setup client with endpoint / api key is enou...
- ACTIVATE DEPLOYMENT PROBLEM...
It's not giving me the option to activate a deployment that says it's ready..
- general_unauthorized_scope
localhost oauth not working. general_unauthorized_scope error showing. { "message": "User (role: guests) missing scopes ([\"account\"])", "code": 401, ...