Back
Server Error when uploading base64 encoded file to storage.createFile() with server-sdk
- 0
- Self Hosted
- Storage
I have a nextjs application, where I want to upload files to appwrite storage. Files are base64 encoded.
I am using: Server sdk: "node-appwrite": "^14.1.0", Appwrite 1.6.0
TypeScript
import {Client, Databases, ID, Storage} from 'node-appwrite';
import {InputFile} from 'node-appwrite/file';
const buffer = Buffer.from(base64Data, 'base64');
try {
await storage.createFile(
process.env.APPWRITE_BUCKET_ID as string,
ID.unique(),
InputFile.fromBuffer(buffer, name),
);
} catch (err) {
console.error('Error:', err);
}
Thats the begin of the base64 string:
TypeScript
base64: 'iVBORw0KGgoAAAANSUhEUgAAB9AAAAfQCAYAAACaOMR5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAuhZJREFUeNrswQEBAAAAgJD+r+4ICgAAAAAAAAAAAAAA
The error is:
TypeScript
Error: AppwriteException: Server Error
at _Client.call (webpack-internal:///(rsc)/./node_modules/node-appwrite/dist/client.mjs:285:19)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async _Client.chunkedUpload (webpack-internal:///(rsc)/./node_modules/node-appwrite/dist/client.mjs:221:20)
at async Storage.createFile (webpack-internal:///(rsc)/./node_modules/node-appwrite/dist/services/storage.mjs:268:16)
at async eval (webpack-internal:///(rsc)/./app/api/data/route.ts:193:25) {
code: 500,
type: 'general_unknown',
response: {
message: 'Server Error',
code: 500,
type: 'general_unknown',
version: '1.6.0'
}
}
TL;DR
Developers experiencing a server error when trying to upload a base64 encoded file to Appwrite storage using server-sdk. The error message indicates a 500 Server Error. Possible issue with how the file is being processed before upload. Verify encoding and the file itself.Recommended threads
- Does 1.9.0 Self Hosted have MongoDB Atla...
I have been playing with the new 1.9.0 update and I am really excited for the MongoDB support. I wanted to ask though if at the current time Appwrite supports b...
- significant increase in CPU usage with 1...
Hi, This is no big deal at all (as everything is working great so far), but I just saw that the update (from 1.8 to 1.9) consumes much more CPU than before (re...
- Issues with executor in Appwrite 1.9.0
Hi, I’ve recently did a fresh install of appwrite 1.9.0 self hosted and when I run a function, it just waits indefinite This is the error from the log: [Er...