As said above, Im trying to upload a json string to my database. However i get the following error:
Uncaught (in promise) AppwriteException: Invalid document structure: Attribute "JSONFile" has invalid type. Value must be a valid string and no longer than 9999 chars. Im pretty sure the issue is the filesize in this case. Now my question. What is the best workaround for this?
What size have you set on the Attribute?
Code that goes with this btw
export async function WriteSheetToDatabase(FileToSend) {
console.log(FileToSend)
//Make JSON string
const JsonData = JSON.stringify(FileToSend);
let SheetID = FileToSend.SheetID;
const userID = await userId;
if (!userID) {
console.error("Could not find active Session!");
return;
}
const fileObject = {
UserID: userID,
JSONFile: JsonData,
SheetID: SheetID,
};
//If there is already an existing version, overwrite new saveData
if (!SheetID) {
//make document with unique ID.
const Doc = await database.createDocument(
process.env.NEXT_PUBLIC_DATABASE_ID,
process.env.NEXT_PUBLIC_SHEET_COLLECTION_ID,
ID.unique(),
fileObject
);
fileObject.SheetID = Doc.$id;
FileToSend.SheetID = fileObject.SheetID;
fileObject.JSONFile = JSON.stringify(FileToSend);
console.log("Saved CharacterSheet");
//Grab doc and grab the $id which is uniqueID. add said ID to to FileToSend.SheetID;
if (fileObject.SheetID !== null) {
await database.updateDocument(
process.env.NEXT_PUBLIC_DATABASE_ID,
process.env.NEXT_PUBLIC_SHEET_COLLECTION_ID,
fileObject.SheetID,
fileObject
);
} else {
console.error("SheetID is null");
}
}
also this only happens when i try to console.log() the data out.
9999
And the string is shorter than that?
yes its: 9011
though I will go over that 9999 when i update the app further
so i need to find a way around it
I am self hosting so if anything needs to be changed i can do that
Recommended threads
- Authentication on custom Websocket Serve...
Hi, I want to use a custom Websocket Server (using Bun) for my application. However I cant really figure out authentication on custom servers. Session cookies ...
- Realtime: Listener not triggered on upda...
I self host appwrite 1.8.1. The genereal functionallity works fine. But my realtime subscription isn't updating. I see "Received heartbeat response from realtim...
- Realtime for files() works almost well, ...
I have been trying to make use of realtime, today (14.03.26) I have pulled all the latest versions of docker images, and sdk available. Whats working: - Conn...