set newFile to "/Users/chris/test_directory/Ferrari-Enzo-004.jpg"
on CURL_TO_LOCAL_FILE(urlToCURL, newFile)
# Good practice: not all urls will parse correctly unless quoted.
# And curl doesn't like spaces in local path strings.
set quotedUrlToCURL to quoted form of urlToCURL
set quotedNewFile to quoted form of newFile
# Done this way so I can visualize the pieces of the command string when testing.
set cmdStr to {¬
"curl", ¬
"--location", ¬
"--user-agent 'Opera/9.70 (Linux ppc64 ; U; en) Presto/2.2.1'", ¬
quotedUrlToCURL, ¬
"--output " & quotedNewFile}
set AppleScript's text item delimiters to " "
set cmdStr to cmdStr as string
set AppleScript's text item delimiters to {""}
do shell script cmdStr
return (POSIX file newFile) as alias
end CURL_TO_LOCAL_FILE
CURL_TO_LOCAL_FILE(urlToCURL, newFile)