jackmin
jackmin

Reputation: 41

How to upload the csv file to ftp server in rails?

I write a function to export the csv data, but i don't know how to request the export url to upload the csv file to ftp server in ruby ? Who can tell me how to do?

Upvotes: 4

Views: 4023

Answers (2)

Dheeraj Maheshwari
Dheeraj Maheshwari

Reputation: 407

It Worked for me you can also try this:

require 'net/ftp'

path = "tmp/" 
filename = 'product.csv'
ftp = Net::FTP.new('ftp.*****.io') 
ftp.login(user = "****", passwd = "******") 
ftp.putbinaryfile(path + filename, filename) 
ftp.quit()

Upvotes: 0

Mashpy Rahman
Mashpy Rahman

Reputation: 696

You can use net/ftp to solve this problem.

require 'net/ftp'
require 'open-uri'
Net::FTP.open('SERVER_Name', 'USER', 'Password') do |ftp|
  ftp.passive = true
  ftp.putbinaryfile("Your.csv")
end

Upvotes: 8

Related Questions