Back

The uploaded file is invalid. Please check the file and try again.

  • 0
  • Self Hosted
  • Web
  • Storage
NewtonX
3 Oct, 2024, 03:39

I had some strange issues with the appwrite self-hosted one. I'm using the node-appwrite npm package to create the file.

But getting error AppwriteException: The uploaded file is invalid. Please check the file and try again.

Strangely, it is created in storage with the correct format, and I can download and use it. This exception caused my angular app not to work properly.

I need help understanding what is happening.

This is payload i got

code: 403 message: "The uploaded file is invalid. Please check the file and try again." type: "storage_invalid_file" version: "1.5.10"

Im not sure why its 403 rather than 400, but my Key is good everything else is working and even thou its creating file on server but still returns error.


NOTE: everything is working, except only when I createFile from Nodejs SDK and it creates the file perfect but throw this exception.

TL;DR
Developers are encountering an issue where they receive an "uploaded file is invalid" error message, despite the file being created correctly on the server. The problem arises when using a method to convert canvas to a file. The error, flagged as a 403 error, is disrupting the functionality of their Angular app. Despite the file being created in storage with the correct format, developers are unable to upload it successfully.
NewtonX
3 Oct, 2024, 03:55

Updated :

I think i found the issue but still cannot understand why this happening:

<input type=file />

any file uploaded via above tag works awesome no errors.

but when i convert the canvas to file that only where it givng erorr, but also upload the file with correct format.

` dataURLToFile ( dataURL: string, filename: string ): File { var blobBin = atob( dataURL.split( ',' )[ 1 ] ); var array = []; for ( var i = 0; i < blobBin.length; i++ ) { array.push( blobBin.charCodeAt( i ) ); } var file = new Blob( [ new Uint8Array( array ) ], { type: 'image/png' } );

TypeScript
return new File( [ file ], filename, { type: 'image/png' } );

} `

above is the method im using to convert

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more