Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Swift |
I want to use HTTPRequest.request() to get a file from google drive. Unfortunately, I couldn’t understand the Drive API. An example would be greatly appreciated.
Here is a link to a jpg that I would like to be able to request:
Here is the best I could do myself, but the code doesn’t work:
func _on_request_file_button_pressed():
var file_prefix = "https://www.googleapis.com/auth/drive/v3/files/"
var file_id = "1Ob8MDzX8sNgr2zFMhefe0l4_nH7HNFlo"
http_request.request(file_prefix + file_id)
func _on_http_request_request_completed(_result, _response_code, _headers, body):
var image = Image.new()
image.load_jpg_from_buffer(body)
var new_texture = ImageTexture.create_from_image(image)
print(new_texture)
set_texture(new_texture)