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
- Any way to temporarily bypass the email ...
Hey guys, any way to bypass the email verification to use the accounts again? i need to recover some projects that due to recent changes have been stopped, and ...
- Collections list not showing up when try...
I'm trying to create new relationship attribute but both one way and two way relationship is not showing up collections list to connect with my relationship att...
- I have try to use the appwrite in to the...
Invalid Origin. Register your new client (oailedjdbkhlkakmnnapoonllbnfmfij) as a new Web (Chrome Extension) platform on your project console dashboard