Panther kills URL Access Scripting uploads?

The following script works fine before Panther:

set x to choose file with prompt “the file?”
set y to text returned of (display dialog “the URL?” default answer “ftp://server.dom/rootDirectory/subDirectory1/sub_N/newItemName”)
tell app “URL Access Scripting”
upload x to y authentication true
end tell

In Panther, it compiles but then fails during run with
“URL Access Scripting got an error: Parameter error.”
BTW: it never gets to the part where it asks for your ftp-user and password.

Using URL Access Scripting Version 1.1 with
AppleScript 1.9.2 on a 12" G4 PowerBook.

Please let me know if you can reproduce this and/or shed any light on the problem.
Thanks.

Does this work?


set x to choose file with prompt "the file?"
set x to (x as string)
return x
set y to text returned of (display dialog "the URL?" default answer "ftp://server.dom/rootDirectory/subDirectory1/sub_N/newItemName")
tell application "URL Access Scripting"
	upload file x to y with authentication
end tell

choose file returns an alias, and URLAS claims to need a file type. I’ve found that applications are sometimes strict with this, and sometimes not. So, my code converts the alias to a plain path string, then uses file x in the upload command. Let us know if that works.

Thanks, but this code doesn’t work either (same error):

Code:

set x to choose file with prompt “the file?”
set x to (x as string)
return x
set y to text returned of (display dialog “the URL?” default answer “ftp://server.dom/rootDirectory/subDirectory1/sub_N/newItemName”)
tell application “URL Access Scripting”
upload file x to y with authentication
end tell

While on the subject of URL Acess Scripting, it also suffers a 2GB file size ceiling, but that’s another bug…

Does this work?

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Thanks, but it doesn’t: same error. FWIW, the download works fine with any of these parameters, but upload reports a parameter error.

Don’t beat yourself up trying to make the upload work, it is broken in Panther. After a lot of effort I finally ascertained from others (here or in the AS forum at apple support) that it is definitely broken. The work-around they suggested was a call to curl (so shell script) in UNIX. This is the script I use to update my website (names changed to protect the innocent):

property fileName : “filepath” as alias
property userLogin : “myAccountAtISP.NET
property userPasword : “myPasswordThere”
property urlToGo : “ftp.isp.net//home_page/” – path to my website

set fullpath to “curl -T " & (POSIX path of fileName) & " ftp://” & userLogin & “:” & userPasword & “@” & urlToGo

try
do shell script fullpath
say “file uploaded”
on error error_message
display dialog error_message
end try

Using cURL is realy the best solution.
Some problems my be correct by using “quoted form of POSIX path” (I use the script from inside FileMaker Pro) :

set fullpath to "curl -T " & (quoted form of POSIX path of leDocument) & " ftp://" & userLogin & ":" & userPasword & "@" & urlToGo

You guys beat me to it! :smiley: I wrote a handler a while ago that does FTP uploading using cURL. You can read about it at http://danshockley.com/codebits.php. It handles some error conditions, and makes an easy interface to include in your own scripts. And, in case you worry about such things, it’s public domain.


-- SAMPLE USAGE
simpleFtpUpload("ftp://ftp.SOMEWHERE.com/", "DriveX:Users:YOU:Desktop:TEMP:some'dir:person's ploy", "testme", "testing12")

on simpleFtpUpload(remoteURL, macFilePath, userName, userPasswd)
        -- version 1.2, Dan Shockley (http://www.danshockley.com)
        -- uses curl to do the upload
        -- remoteURL is the complete ftp url to the remote destination directory
        try
                if userName is "" then
                        set userName to "anonymous"
                        set userPasswd to "devnull@devnull.null"
                        -- no email address, change if desired
                end if
                
                -- get parentFolder
                if (macFilePath as string) ends with ":" then -- it is a folder itself
                        set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
                        set parentFolder to (text items 1 thru -3 of (macFilePath as string)) as string
                        set AppleScript's text item delimiters to od
                else -- it is just a file
                        set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
                        set parentFolder to (text items 1 thru -2 of (macFilePath as string)) as string
                        set AppleScript's text item delimiters to od
                end if
                
                set localPosixPath to quoted form of POSIX path of alias macFilePath
                
                set uploadFileName to do shell script "basename " & localPosixPath
                set uploadDirectory to quoted form of POSIX path of parentFolder
                
                -- curl --upload-file SOMEFILE ftp://SERVER.com --user MYUSER:THEPASSWD
                -- must be IN the directory of the file you want to upload
                set myCommand to "cd " & uploadDirectory & ";" & "curl --upload-file "
                set myCommand to myCommand & quoted form of uploadFileName
                set myCommand to myCommand & " " & remoteURL
                set myCommand to myCommand & " --user " & userName & ":" & userPasswd
                set myCommand to myCommand & " " & "--write-out " & "%{size_upload}"
                set myCommand to myCommand & " --quote -quit"
                
                -- output is the 'size_upload' result from curl
                
                set uploadResult to do shell script myCommand
                
                return uploadResult -- size uploaded in kilobytes
        on error errMsg number errNum
                error "simpleFtpUpload FAILED: " & errMsg number errNum
        end try
end simpleFtpUpload