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
- 1:1 relationship doesn’t sync after re-a...
Hi, I’m trying to use a two-way one-to-one relationship. It works fine when I create a record with the relationship set, and it also works when I unset it. But ...
- Upsert with setting permissions
Hi there, I am using self-hosted appwrite v1.7.4 and trying to use the bulk update stuff that was released with 1.7.x. Unfortunally I found that there is an ser...
- Github connection error - Self Hosted Ap...
I am trying to connect my github account to deploy a project to sites, but Connect to Gtihub button is disabled. I have configured all Env variables needed for...