"FTP Upload" Droplet Question

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

To run a progress bar, you need some indication of progress, but one that works for plain vanilla applescripts is BPProgressBar

To determine if a file is a folder:

if f's kind is "folder" then whatever...

The FTP-clients give you more flexibility and more comfortable status reports than a simple droplet ever can
If you have access to the full path of your server, it’s very easy to install a resticted area with .htaccess.
(Full path means the path starting from root, not from your domain name)

And, Stefan’s method is the safest and most secure way to go. Your clients can’t see anything but what they’re meant to, and that usually means only what they have uploaded themselves (so they can change that if they have to). If you have multiple clients, prepare several special areas of access, one for each.

Thanks for the input, everyone. I’ll rethink how I want to approach this.

I’m really just trying to make this solution as invisible as possible. I want the clients’ experience in this area to be as Apple-like as possible, if that makes any sense. I just want them to be able to drop the file onto an icon and walk away (or otherwise move on). Transmit lets me make a droplet that will do this, and maybe I’ll stick with that (and change the droplet’s icon to include my logo or something).

I’ve just started with using FTP this way, and I am wondering how I can create usernames and passwords for my server (it’s not actually my server, the site is hosted by GoDaddy). I’ve poked around in the host’s settings, by I don’t see any sort of account-creation areas.

Sorry I sort of hijacked my own thread…

Thanks again!

Doug

Hi Doug,

look at this tutorial about htaccess

http://www.freewebmasterhelp.com/tutorials/htaccess/

I doubt GoDaddy is going to let him mess around with .htaccess, but I suppose it’s possible.

I would try contacting Go Daddy directly. Most likely if they allow multiple FTP accounts they have a web interface like Plesk through which it would be handled.