Back
Server Error when uploading base64 encoded file to storage.createFile() with server-sdk
- 0
- Self Hosted
- Storage
shekpaar
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
- Having issues with login via CLI
``` ~/appwrite appwrite login --endpoint https://localhost/v1 --verbose ? Enter your email myvalidemai...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...