-
Notifications
You must be signed in to change notification settings - Fork 9
/
ftp_upload.rb
45 lines (36 loc) · 1.01 KB
/
ftp_upload.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#Jesly Varghese 2012
#FTP Module
#This class deals with the upload of ipa, manifest and icon to remote ftp server
#Improvement needed, support for SFTP, Upload to dropbox, or using dropbox as ipa host is
#a viable option
require 'rubygems'
require 'net/ftp'
require 'ftpfxp'
module FTP
DEFAULT_PORT = 21
def self.upload(server, project, *files)
ftp = nil
if server[:secure]
ftp = Net::FTPFXPTLS.new server[:hostname]
else
ftp = Net::FTP.new
ftp.connect server[:hostname]
end
ftp.passive = true
ftp.login server[:username], server[:pass]
ftp.chdir server[:upload_path]
dir_contents = ftp.nlst
ftp.mkdir project[:name] unless dir_contents.include? project[:name]
ftp.chdir project[:name]
ftp.mkdir project[:build_number]
ftp.chdir project[:build_number]
files.each do |file|
begin
ftp.putbinaryfile file, File.basename(file) unless file.nil?
rescue
next
end
end
ftp.quit
end
end