appwrite
appwrite copied to clipboard
Error Uploading to my bucket from form (Nodejs) - Backend
Now I've created a form to upload files to my bucket using nodejs as my backend and reactjs as the frontend now every time i click my forms submit button it says these on the Network on the Inspect
{"message":"An error occurred while uploading data","error":"Cannot read properties of undefined (reading 'size')"}
what is the cause and can you help me
@M23jJohn, thanks for creating this issue! 🙏🏼
You will probably need to import InputFile from node-appwrite/file and use one of the methods from there.
If you're still having trouble, it would be best to create a support post on Discord as it's easier to troubleshoot on Discord than GitHub.
OMG, this should be included somewhere in the documentation.
I spent hours stucking at SyntaxError: The requested module 'node-appwrite' does not provide an export named 'InputFile'
The InputFile class from node-appwrite not node-appwrite/file is misleading. As a desparate approach, I tried to create my own copy of the inputFile class, managed to format the object with the exact same parameters but it doesn't work...
// node-appwrite
export class InputFile {
constructor(stream: NodeJS.ReadableStream, filename: string, size: number);
}
// InputFile object sent
{"stream":{"_readableState":{"objectMode":true,"highWaterMark":16,"buffer":{"head":null,"tail":null,"length":0},"length":0,"pipes":[],"flowing":null,"ended":false,"endEmitted":false,"reading":false,"constructed":true,"sync":true,"needReadable":false,"emittedReadable":false,"readableListening":false,"resumeScheduled":false,"errorEmitted":false,"emitClose":true,"autoDestroy":true,"destroyed":false,"errored":null,"closed":false,"closeEmitted":false,"defaultEncoding":"utf8","awaitDrainWriters":null,"multiAwaitDrain":false,"readingMore":false,"dataEmitted":false,"decoder":null,"encoding":null},"_events":{},"_eventsCount":0},"filename":"2.png","size":119942}