I'm trying to figure out how to upload the complete contents of a JSON file to a firestore. I thought I could access them through filepicker.data, but that doesn't appear to return any data.
I don't want to parse the JSON, I just want to upload the file as a text string.
If you looking to insert a whole file into Firestore using the Filepicker component, one way is to break the file object down into it's individual keys (base64 data, name, type) and insert them all into firestore:
You can also send up the JSON object by accessing the {{filepicker.parsedValue}}, this will send the full object and retain it's nested structure in Firestore:
Thanks for this. The stringify function I think will solve all my woes
BUT… for some reason I’m not seeing any parsed value for the specific .json file that I’m trying to upload. Other files (.txt / .jpg) all appear to upload fine, but these don’t. Is there something obvious I’m missing here…? Happy to share an example file if that helps… !
okay, so I’m zeroing in here… The original file, as created uploaded shows nothing - but if I remake it, it appears to work. So… there’s something wrong with the original, but I really can’t see what…?
It’s really strange… So, this is the JSON that’s auto-compiled by Unity, but it openable and readable by a text editor (ie. it exists!). I’m not at all sure what to be looking for now…
The compiler I’m using to make the JSON files puts a 2byte BOM at the beginning of the JSON file, which I guess is what retool isn’t liking.
So I guess the next question is - is this something that’s possible to workaround from the retool side, or do I need to find a different solution at my end…?
strange. Ummm well if the file won’t upload data at all (not displaying the base64 value), then you might be out of luck in terms of parsing. But if there’s a base64 value in there, you could try and work around it by manually parsing the data using different a library with functions you know will work.