info(“urltaskinfo”)

The info(“urltaskinfo”) function returns information about a just completed HTTP download.


Description

This function returns a dictionary with information about a just completed HTTP download. To do this, the first statement in the urltask( completion code should be the urltaskstatus statement. Then at a later point, the code can use the info(“urltaskinfo”) function to get a dictionary that contains all of the available information about the download.

This example downloads an image into a file. The filename is not specified, only the folder, so the filename returned from the web server will be used. After the download is complete the image will be opened in the Preview application.

local siteurl,image
siteurl=...
imageurl=...
taskid = urltask(siteurl+image,
    "file","~/Pictures/WebStuff/",
    "code",{
        urltaskstatus
        local imagefile
        imagefile=getdictionaryvalue(info("urltaskinfo"),"FILENAME")
        openwith "Preview","~/Pictures/WebStuff/"+imagefile
    }
)

The information available from the urltaskstatus function is:

MIME – Mime type of the returned data, for example text/plain, text/html, or image/jpg.

FILENAME – The filename suggested by the server for this content.

ENCODING – If the content is text, this is the encoding of the text, for example UTF-8. Note: This information is sometimes missing.


See Also


History

VersionStatusNotes
10.0NewNew in this version.