Error uploading file: TypeError: Cannot read properties of undefined (reading 'fromPath')
- 0
- Storage
Hi, I am trying to upload the file, but I an unable to do so.
Kindly assist
const uploadFile = async (filePath) => { try { if (!fs.existsSync(filePath)) { throw new Error("File does not exist: " + filePath); }
// console.log(fs.readFileSync(filePath));
// ("/fix");
// Upload file with InputFile
const resultUpload = await storage.createFile(
"__",
ID.unique(),
InputFile.fromPath("./images.jpeg", "images.jpeg"),
[
Permission.read(Role.any()),
Permission.update(Role.users()),
Permission.delete(Role.users()),
]
);
console.log(resultUpload);
// console.log("File uploaded successfully:", resultUpload);
return resultUpload;
} catch (error) { console.error("Error uploading file:", error); } };
Recommended threads
- WEBP preview not working after upgrading...
Only with preview, I'm getting this error: {"message":"no decode delegate for this image format `WEBP' @ error\/blob.c\/BlobToImage\/481","code":400,"type":"sto...
- Storage usage keeps going up
I have a self-hosted instance running in production for over a year now. The deployment has seen multiple updates and migrations of Appwrite versions. What I ha...
- SSR Image Previews
I am using the SSR guide (with SvelteKit) to use Appwrite on both the server and the client. I do this by also passing the cookie back to the client and creatin...