0 votes

Alright. I was trying to see if I could use an HTTP Request to download an exe file and an x86_64 file from GitHub. I've tried many was to succeed in it, but it never prospered. this is an example of what I tried to do.

What this is supposed to do its download the file & put it into the apps directory of my app.

func DownloadTestApp(result, response_code, headers, body):
    print(body)
    print(result)
    print(response_code)
    print(headers)
    if (current_app.file_exists("user://apps/TestApp.exe")):
        OS.alert("File Exists", "Error")
        http_request.cancel_request()
    else:
        var f = File.new()
        f.open("user://apps/TestApp.exe", File.WRITE)
        f.store_buffer(body)
        f.close()
        http_request.cancel_request()
    pass

What this is supposed to do is find what button I pressed in a Menu Button & do what it needs to do to start the download.

func _item_pressed(id):
var user_path = OS.get_user_data_dir()
var item_name = $DownloadPrograms.get_popup().get_item_text(id)
if item_name == "TestApp":
    OS.alert("The software will now continue to download TestApp", "Download")
    http_request.connect("request_completed", self, "DownloadTestApp")
    http_request.request("https://github.com/Blockyheadman/TestApp/blob/main/apps/TestApp.exe?raw=true")
    http_request.set_download_file(user_path+"/"+"apps"+"/"+"TestApp.exe")

Please note that the url that's included isn't real. It's the same thing as my personal url but some names are changed

Godot version 3.4.3
in Engine by (29 points)

This site is about questions. What is your one?

how to download a file from GitHub. Like I stated before, I tried many different ways to complete that, but it never really worked.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.