How to send a resource to a server?

I’m trying to send a resource from a client to a server through a RPC method on Godot 4.2.1.
Now, directly sending the resource doesn’t work, thanks to a bug that throws a “resource_name hides a global script class” error. In the GitHub issue someone mentioned that using inst_to_dict() before sending and dict_to_inst() after receiving might solve the problem, however, I get the following error on the server:
Invalid instance dictionary format (can't load script at @path)
I did made sure that the resource has the same path on both the client and the server.
Maybe I’m just misunderstanding dict_to_inst()? There’s also a note in the docs about the method not working with built-in scripts, but honestly, I didn’t quite understand what that means.
Also, yes, there is another proposed workaround in the GitHub issue, that (as far as I understood) saves the resource to the disk, gets the file as a PackedByteArray, sends that to the server, the server saves that as a file and then opens it as a resource. But, like, this can’t be the best way to do this!? I just want to send a resource that contains three variables over to the server, and for that the workaround is way to complicated.

How do you send it? I think the step should be:

  • client
    • var data = inst_to_dict(object)
    • rpc(data)
  • server
    • dict_to_inst(data)

Also, you can debug it by printing data on both client and server, see what’s the diffrence.

1 Like

Thank you, I’m just an idiot.
After printing the dictionaries, turns out that on the client, a folder was called “ressource”, but on the server it was called “resource”. I hate myself.

1 Like

happens to the best of us