Hi Everyone,
I have clients that need to upload files to my ftp server, but I don’t want them to have to launch Fetch or Transmit and I dont 'want them to be able to see the contents of the server. I’m trying to write a droplet that will let them just drop the file and get a progress bar (any commercial solutions would be great, also). Thanks to Dan Shockley and some posts here, I’ve got the droplet working, but I can’t figure out how to get the progress info. Files will be sent one at a time, but are hundreds of megs each, so the upload progress is essential. I’m using this script:
simpleFtpUpload("ftp://ftp.foo.com/", "Macintosh HD:bar.jpg", "foo", "bar")
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
--display dialog "parentFolder"
--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
display dialog parentFolder
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
I’m totally new to this side of Applescript, and any help would be greatly appreciated.
Thanks a lot!
Doug