ARDownloadFile

From Blue Mars Developer Guidebook

Jump to: navigation, search
There are security restrictions on this article

This is a Web function.

Contents

Function

ARDownloadFile(url, destfile, options)
start downloading a file from the specified URL, save with specified filename
return value - true if a download is successfully started, false if not (missing parameters, another download in progress...)
url - URL of remote file
destfile - filename in which to save the download. This file will be located under the Blue Mars user folder.
options - optional table of download parameters, which may contain the possible key-value pairs

Parameters

These are the optional download parameters:

agent - contents of the User-Agent header (used to identify the browser type). Defaults to "Blue Mars"
referer - contents of the Referer header (used to identify the referring web site).
cert - if true, verify server SSL certificate. Defaults to true.
certfile - pathname of the certificate file used for SSL server authentication. Default is the ca-bundle.crt in the top-level Blue Mars directory.
post - urlencoded post data
redirect - number of redirects to follow. -1 specifies infinite redirects
head - use HTTP HEAD method, which tells the server not to return content. Use if you just want to check GetDownloadFileTime without actually downloading the file.
service - the network service to use (defaults to "AvatarReality")
new - create a new downloader for this download

[Update] from release 12/16/2010 this function no longer sends referer by default.

Usage

Notes

  • This function replaces Game.DownloadFile.
  • Only one download can be in progress at a time. Check Game.IsDownloading before starting a new download.
  • This function is named DownloadFile for historical reasons, as it was originally used for downloading maps and patches. It is just as valid for submitting information to a web server, using either POST or GET methods, but the content returned by the web server is always saved as a file (even, e.g. if it's the HTML displaying "404 Not Found".
  • If new=true is specified, then that downloader instance can be referred to by specifying the "file" parameter in the other download functions.
  • If new=true is specified, then remember to clean up the new downloader instance when you're done with it, using Game.RemoveDownload.

Examples

A simple example (just a GET request):

ARDownloadFile(url,"test.html"));

where url is any valid web URL

A POST request passing "firstname" and "lastname" parameters:

ARDownloadFile(url,"test.html",{post="firstname=blue&lastname=mars"});

Download using an external downloader.

ARDownloadFile(url,"test.html",{service="ARExternal"});

Create two new downloader objects and perform the downloads concurrently.

ARDownloadFile(url,"test.html",{new=true});
ARDownloadFile(url2,"test2.html",{new=true});


ARDownloadFile is used by some Web Utilities.

Problems with this wiki page? Contact us either by: Support Email or Support Ticket System

Blue Mars Guidebook Privacy Policy
Blue Mars Guidebook Community Guidelines

Personal tools