[英]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 ?我写了一个函数来导出 csv 数据,但我不知道如何请求导出 url 将 csv 文件上传到 ruby 中的 ftp 服务器? Who can tell me how to do?
谁能告诉我怎么办?
You can use net/ftp to solve this problem.您可以使用 net/ftp 来解决此问题。
require 'net/ftp'
require 'open-uri'
Net::FTP.open('SERVER_Name', 'USER', 'Password') do |ftp|
ftp.passive = true
ftp.putbinaryfile("Your.csv")
end
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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.