User Tools

Site Tools


start:wiki:engines:godot4:faq:web:download

How download file, Godot web / Как скачать файл под web в Godot

Скачиваем png картинку:

downloadPng.gd
func save_png(img : Image, path : String, filename : String): 
    var err = img.save_png(path+"/"+filename+".png")
    # Тут требуется вставить проверки err на ошибки 
    Download_File(path+"/"+filename+".png",filename)

Коды ошибок для err

Скачиваем как обычный двоичный файл:

downloadFile.gd
func download_file(path : String, filename : String):
    var f = File.new()
    f.open(path,File.READ)
    var buf = f.get_buffer(f.get_len())
    JavaScript.download_buffer(buf,filename+".png")
    f.close()

start/wiki/engines/godot4/faq/web/download.txt · Last modified: 2024/05/24 15:40 by rufus

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki