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
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- 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 ...