Fileupload - contents of a JSON file as a string to firestore

Hi there,

Relative noob!

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.

Any help much appreciated!

Hi @mrsimons! Welcome to the community! :sunglasses:

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:

If you're not looking to have a nested object in Firestore, it can also be converted to a string beforehand:

If you're not seeing these values being displayed, you can check the left panel to see exactly what's available:

1 Like

Hey Ben,

Thanks for this. The stringify function I think will solve all my woes :slight_smile:

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… !

@mrsimons sharing the example file would be helpful! Is it just this one particular file, or all of them that won’t seem to parse?

It’s just this particular type, it seems.

I can only attach images to the forum, so here’s a gist of it.

Thanks, Ben!

Not very helpful.. but this works for me :upside_down_face:

Are you able to see the unparsed data? Like the file object with base64 data inside the uploader?

huh…

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…

MORE PROGRESS…

So, it seems the problem is this : https://en.wikipedia.org/wiki/Byte_order_mark

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.