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
- When I set User Permissions, correct ses...
When I set role to "Any" or "All users", it works. When I check the upload, it has the correct `user:679f5f8a00035fe3b984` When I open the `http://localhost:30...
- Connection Speed
Hey, I'm looking to integrate Appwritre for my project and I'm waiting for the expansion of datacenters to Canada/the US (which I have heard will be in Q1)! ...
- Can function events be triggered when de...
I am a developing an appwrite function locally. I am not sure how to add a trigger for bucket file creation events. I added in the appwrite.json into the events...