+3 votes

I have uploaded some photos on googledrive and use HTTPREQUEST to download them.Then I use getdownloadedbytes() and getbodysize() to track the progress.

However, when the file exceed 2MB, the body size will always return -1 and downloaded byte returns 0. But it will eventually finish the download and everything seems to work fine afterwards.

Here are the test project:

Click "<2MB" or ">2MB" will start downloading the file to "user://" and after the donwload succeeded, click "Show" will show the photo.

Both will download successfully but the larger file will only show 0%. I print out the body size and downloaded byte in the debug and it shows -1 and 0 in body size and downloaded byte. and when about to finish downloading, the downloadedbyte will show correct number but body size keeps -1. But the smaller file will show the correct number for both.

Here are more test photos:


Just replace the string after "id=" in $HTTPRequest.request("https://drive.google.com/uc?id=1Wvx0Rqk3cPIgKrDQAdjHtqdN4UxTlqzq")

Below is the code.

extends Node2D

var status = 123
var downloaded_bytes = 123
var body_size = 123
var progress = 123
onready var download_status = get_node("DownloadStatus")

func _ready():

func _process(delta):
    status = $HTTPRequest.get_http_client_status()
    downloaded_bytes = $HTTPRequest.get_downloaded_bytes()
    body_size = $HTTPRequest.get_body_size()
    print("Status: ", status)
    print("Downloadedbytes: ", downloaded_bytes)
    print("BodySize: ", body_size)
    if status == 6 or status == 3 or status == 1:
        download_status.text = "Connecting to Server..."
    elif status == 7:
        progress = (downloaded_bytes * 100 / body_size) 
        download_status.text = str(progress) + " %"
    elif status == 5:
        download_status.text = "Server Connected"
    elif status == 4 or status == 2:
        download_status.text = "Can't connect to the server" 
        download_status.text = "Error"

func _on_HTTPRequest_request_completed( result, response_code, headers, body ):
    download_status.text = "Download Completed"
    print("Request completed ", " result: ", result, " response_code: ", response_code, " body: ", body)

func set_texture(photo_name):
    var image = Image.new()
    image.load("user://%s.png" %photo_name)
    var image_texture = ImageTexture.new()
    $TextureRect.texture = image_texture

func _on_Button1_pressed():

func _on_Button2_pressed():

func _on_Button3_pressed():

func _on_Button4_pressed():

I have no idea what is happening. The body size is just 2141681. It is way beyond the limit of integer but it gives me -1.

in Engine by (59 points)
edited by

I also have this problem in version 3.3
In version 3.2.3 it works correctly

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.