Topic: Script to upload a file to FTP, wait and upload the next file

Hi,

I have just purchased DropZone as it looks like a nice programme and I love the idea of the scripting options.

I have been looking at the FTP script as what I am trying to create is a script that uploads a file to a ftp server, waits 5 minutes and then starts the next transfer.  Its important that it only uploads one file at a time and then waits long enough for the script on the other end to start processing.

Can I simple add some kind of pause to the default script?

Anyone got any ideas or suggestions?

Alan

Re: Script to upload a file to FTP, wait and upload the next file

I had a little play and have a script based on the standard FTP one but when I add three small files it doesn't wait between files so not sure where I need to pause in the loop (so to speak).

# Dropzone Action Info
# Name: FTP Upload Copy
# Description: Allows files to be uploaded to a remote FTP server.
# Handles: Files
# Creator: Aptonic Software
# URL: http://aptonic.com
# OptionsNIB: ExtendedLogin
# Events: Dragged, TestConnection
# KeyModifiers: Option
# SkipConfig: No
# RunsSandboxed: Yes
# Version: 1.0
# MinDropzoneVersion: 3.0

$host_info = {:server    => ENV['server'],
              :port      => ENV['port'],
              :username  => ENV['username'],
              :password  => ENV['password']}

def dragged
  delete_zip = false
 
  items = $items
 
  $dz.begin("Starting transfer...")
  $dz.determinate(false)
 
  remote_paths = FTP.do_upload(items, ENV['remote_path'], $host_info)
  # ZipFiles.delete_zip(items) if delete_zip
 
  # Put URL of uploaded file on pasteboard
  finish_text = "Upload Complete"
 
  if remote_paths.length == 1
    filename = remote_paths[0].split(File::SEPARATOR)[-1].strip
   
    if ENV['root_url'] != nil
      slash = (ENV['root_url'][-1,1] == "/" ? "" : "/")
      url = ENV['root_url'] + slash + filename
      finish_text = "URL is now on clipboard"
    else
      url = filename
    end
  else
    url = false
  end
  sleep 600
  $dz.finish(finish_text)
  $dz.url(url)
end

def test_connection
  FTP.test_connection($host_info)
end

Re: Script to upload a file to FTP, wait and upload the next file

Hi Alan,

I've made you a custom version of the FTP action that waits 8 minutes between uploads. If you need to change the delay, you can edit the ftp_custom.rb file inside the action bundle and change line 96. The trick was there's another library bundled with Dropzone that does the actual uploading so I've made you a custom version of this lib and bundled it along with the action.

You can download the action here: http://shipsomecode.com/misc/FTP%20Uplo … bundle.zip
Unzip it and double click the "FTP Upload With Delay.dzbundle" action bundle to add it to your grid.