Getting an object as as scene file as text (without saving it)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MOSN

So I’m making a project on GitHub which involves uploading scene files to GitHub from within the game. To do that I need them as text which I can then Base64-encode with Marshalls.utf8_to_base64.
This works perfectly fine for an existing file within the project where I can do the following:

var file = File.new()
file.open("res://SceneFile/0.tscn", file.READ)
var content = file.get_as_text()
file.close()

However the problem is I want to do this for scene objects that don’t already exist within the project as files. In other words nodes that exist within the game which I could normally just save with PackedScene and ResourceSaver. Problem is when the game is run as HTML5 hosted on GitHub I’m fairly sure (?) I can’t just save a file to a path and then open it (since the game isn’t in an actual directory on your computer). Please do let me know if I’m wrong about that, but regardless it would be optimal if I could do this without having to save the file.

So essentially is it possible to get an object - as a scene file - as text, without first saving that object as a file.