I'm trying to create a setup process for new accounts that use my app. On creating a new account, it's important to establish the default values for new users. One of those is a (mostly empty) Entity File called "CompletedQuests.json" that I'm using to save data.
I don't want to upload this file initially from the client in case the client isn't trustworthy or the app has been tampered with. So I was hoping to create a file on the server and place it among the 10 Entity files we're allowed to have. The code:
handlers.giveNewChariteerAccountDefaultEntityValues = function (args, context) { // Use this entity! var entityProfile = context.currentEntity; log.debug("Did this work? Trying to set a file..."); entity.SetObjects({ Entity: entityProfile.Entity, Objects: [ { ObjectName: "TestObject", DataObject: { item1: "This is Item 1", item2: "This is Item 2" } } ] }); var filename1 = "TestFile1"; var filename2 = "TestFile2"; // ** Here is where I would put data into filename1 and filename 2 ** entity.InitiateFileUploads({ Entity: entityProfile.Entity, Filenames: [ { filename1, filename2 } ] }); return; }
You can ignore the SetObjects call, that was just to make sure things were working. So that works, but I can't seem to figure out how to InitiateFileUploads.
Is there a specific server function I can use like SetFiles, similar to SetObjects? That would be convenient. The file is just JSON and when a new account is created, as I said, it barely has to have anything in it.
CompletedQuests.json
{ "completedQuests":[] }
That's all I would need! Now it was my understanding that you don't have to upload / finalize things on the server because it's the server but I guess I was wrong. I'm getting this error:
"result": null, "apiError": { "code": 400, "status": "BadRequest", "error": "InvalidParams", "errorCode": 1000, "errorMessage": "The resource Profile/Files/ was not valid. Error: Path must contain a value.", "errorHash": null, "errorDetails": null }
Couldn't find any information about the error online so I wanted to ask. I'm finding EntityProfiles confusing, even more so since the rules for the server are different than rules for the client.
Thanks for the help!