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
- Other DateTime Columns Are Saved Incorre...
When opening a rowβs details from the console and editing any field, the timestamps of other DateTime columns are being automatically changed and incorrectly sa...
- Github App "Failed to retrieve access to...
When trying to connect the Github App on 1.8.1 I recieve this error: ```[Error] Method: GET [Error] URL: /v1/vcs/github/callback [Error] Type: Exception [Error]...
- GOT 500 error when going to the appwrite...
I gott 500 internal error screen and my API is timeout. please help to take a look. Traceback (most recent call last): File "D:\conda\envs\wrista\Lib\site-pa...