Skip to content

http.download

João Matos edited this page May 15, 2016 · 15 revisions

Downloads an HTTP resource from the specified URL to a file.

http.download("url", "file", progress, headers)

Parameters

url is the URL to be downloaded. file is the destination path where the resource will be saved. progress is an optional Lua callback function that receives two numeric arguments representing total and current download progress in bytes. headers is an optional Lua table with HTTP headers to be used on the request.

Return Value

True if successful, otherwise nil and an error message.

Examples

http.download("http://example.com/file.zip", "file.zip")
http.download("http://example.com/file.zip", "file.zip", nil, {"From: Premake", "Referer: Premake"})

Availability

Premake 5.0 or later.

See Also

Clone this wiki locally