Can you read/write to file that's not stored locally?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Svampen
:warning: Old Version Published before Godot 3 was released.

I’m trying to implement a highscore mechanic for a HTML5 game that i’m trying to make and my question is pretty much as stated above.

Is it possible to use File.open to read/write to a file located on a HTML server using IP or domain adress, given you have server permissions?

something like:

file = File.new()
file.open(“http:www.exampledomain.com/examplefile.json”)

First i was thinking of using the SQLite module by khairul169 i found here.
But i’m having trouble compiling the HTML export templates and using SQL for a highscore mechanic sounds like a bit of a overkill.

Thank you for your help!

:bust_in_silhouette: Reply From: Artium Nihamkin

The way you have written this will not work as a URL is not a path on the file system.

The closest way to implement what you want is to use an http service that have some storage, and use HTTPClient to communicate with it.

It is quite simple, and many cloud providers have a free tier that may be sufficient for your needs.

You write your own service or use an a “key-value” database. If you are afraid touching these subjects yourself, you can try a complete “key value” cloud service such as this one.

For example, you could request https://www.example.com/highscore/list to get the list of high scores and https://www.example.com/highscore/myname/193 to put a new high score in the list.

Notice though, that this makes your game hackable, as anybody could send these requests and set any high score for any player.