Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement some way to save files to real file system in a HTML5 version of a Godot game. #18947

Closed
Ivoch opened this issue May 16, 2018 · 13 comments

Comments

@Ivoch
Copy link

Ivoch commented May 16, 2018

Godot version: 3

OS/device including version: HTML5

Issue description: There is currently no way to save/download files from within a HTML5 version of a Godot game.

Steps to reproduce: Create a small project with one Button and one FileDialog that saves an arbitrary text file. Works as expected in all exported versions, except HTML5. There is currently no way to save a file locally from HTML5, for example save games. FileDialog shows some virtual file system, probably in the browser sandbox mode. The file is only saved there and is inaccessible from the local OS or the server backend.

Minimal reproduction project:
htmlsave.zip

@vnen
Copy link
Member

vnen commented May 17, 2018

I think this a browser limitation, it doesn't let JavaScript or WebAssembly mess with the host filesystem.

@akien-mga
Copy link
Member

CC @eska014

@leonkrause
Copy link
Contributor

leonkrause commented May 17, 2018

We can open a native file dialog. But if I add a function for that to OS, it'll have to be implemented on all platforms

@Geequlim
Copy link
Member

@eska014 Here is already implemented for Window, Linux (GTK+), and macOS
https://github.com/GodotExplorer/NativeDialogs

@Calinou
Copy link
Member

Calinou commented May 17, 2018

Also see this thread on the Godot subreddit in which I suggested @Ivoch to open an issue here.

@Zylann
Copy link
Contributor

Zylann commented May 17, 2018

Can't we use local storage? That's still not accessing the filesystem in general, but it does save stuff to a place on the filesystem.

@leonkrause
Copy link
Contributor

Persistent user:// filesystem already works, using IndexedDB. This issue is about saving data from Godot as a file to the real file system.

The problem is, do we want to maintain functionality to open a native file dialog, e.g. OS.native_file_save()/_open(), for all platforms? This practically seems to be needed only for the HTML5 platform. On the other hand, I want to keep the number of HTML5-specific APIs as low as possible

@Zylann
Copy link
Contributor

Zylann commented May 17, 2018

Or at least, we could use interoperability so that HTML5-specific stuff that we can't put in Godot can be done with JS?

@leonkrause
Copy link
Contributor

You can already execute JavaScript in the browser using JavaScript.eval()

@raymoo
Copy link
Contributor

raymoo commented May 21, 2018

On Android it would mean not having to make FileDialog touchscreen-friendly

@37TS
Copy link

37TS commented May 22, 2018

What about an encrypted CSV with a dev-selected private key as an option to fill in the export settings?
The key could then be stored somewhere in the "project_name.pck" resource file and the CSV could be part of the project or the dev could prompt the user to save the CSV in a read/write folder of choice for saving purposes.

(mere guess, I mean, that's what I was planning for my own html5 projects, either we get such a functionality or not)

@leonkrause leonkrause changed the title Implement some way to save files in a HTML5 version of a Godot game. Implement some way to save files to real file system in a HTML5 version of a Godot game. May 31, 2018
@Calinou
Copy link
Member

Calinou commented Oct 2, 2019

Can JavaScript even force the browser to open a native file dialog? I don't remember seeing this, unless the browser is configured to ask for download location every time.

We can however force a download using JavaScript, including from a Base64 data URI or similar. Just make sure not to initiate several downloads at once, or the browser will prompt the user before starting (Firefox does this at least). The file location is chosen by the browser, there's no way to override it.

Maybe this can be implemented using the JavaScript singleton, in which case we could delegate this to a third-party asset.

@Calinou
Copy link
Member

Calinou commented May 26, 2020

Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants