Using httprequest and wait for the download before I can use it
Asked Answered
R

8

0

I am using http request to downlaod a file.
It works, but I don not konw when the file dowload is done.
So how do I change this code so I get a signal that the download is complete.
And then I can go on loading the file.

@onready var req = $HTTPRequest

req.download_file = "download.gltf"
req.request("http://192.168.2.147:11613/TestCube2.gltf")

I am using Godot 4.1 and GDScript

Repine answered 16/10, 2023 at 5:56 Comment(0)
M
0

If the entire file is sent back in a single response, use the request_completed signal. There are examples here:
https://docs.godotengine.org/en/4.1/classes/class_httprequest.html#

If it's a multipart download, it gets more complicated.

Mansard answered 16/10, 2023 at 7:6 Comment(0)
M
0

My examples would look the same as those examples.

Are there specific lines that you don't understand?

Mansard answered 16/10, 2023 at 7:40 Comment(0)
R
0

Mansard
Thanks No i have solved it

Repine answered 16/10, 2023 at 8:8 Comment(0)
R
0

I got this to work, but now I want it to work with VR for my Meta Quest 2,
Anyone that have solved this?

Repine answered 23/10, 2023 at 14:14 Comment(0)
M
0

To get help, you may need to ask more specific questions.

Mansard answered 23/10, 2023 at 15:31 Comment(0)
R
0

I see.
I have made an HTTPRequest and I got response_code = 200 indicating that the downlaod worked.
I called the file download.gltf but I do not know where the file is stored in my Meat Quest 2.
At least I think this is the problem.
So what path should i use to get the downloaded file?

I have tried "res://download.gltf"

Repine answered 24/10, 2023 at 10:30 Comment(0)
B
0

Repine I have tried "res://download.gltf"

The resource file system is read-only, you are not allowed to save or change files in it. Save your file to the user file system: user://download.gltf

https://docs.godotengine.org/en/latest/tutorials/scripting/filesystem.html#user-path

Biannulate answered 24/10, 2023 at 12:37 Comment(0)
R
0

Biannulate
Thank you. Finaly I got it to work!

Repine answered 24/10, 2023 at 12:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.