从ruby on rails项目的外部下载文件。

时间:2022-06-01 17:08:14

I have a files in my server the following location. "/home/files/*.doc". My Project location is "/home/bld/.." Is there way to download the doc file from the folder "/home/files/x.doc" using the ruby code. The documents folder is located from outside of my project folder,

我的服务器中有一个文件位于以下位置。“/ home /文件/ * . doc”。我的项目地点是"/home/bld/.."是否有办法从“/home/files/x”文件夹下载doc文件?使用ruby代码。文档文件夹位于我的项目文件夹之外,

2 个解决方案

#1


1  

Shouldn't be an issue simply doing:

不应该只是做:

send_file('/home/files/*.doc')

No?

没有?

#2


0  

You don't need to download it while it is on the same computer. You need to copy it

你不需要在同一台电脑上下载它。你需要复制它

Dir['/home/files/*.doc'].each do |file|
  File.cp file, "/home/bld/public/my_docs" # /home/bld/public/my_docs can be any dir
end

#1


1  

Shouldn't be an issue simply doing:

不应该只是做:

send_file('/home/files/*.doc')

No?

没有?

#2


0  

You don't need to download it while it is on the same computer. You need to copy it

你不需要在同一台电脑上下载它。你需要复制它

Dir['/home/files/*.doc'].each do |file|
  File.cp file, "/home/bld/public/my_docs" # /home/bld/public/my_docs can be any dir
end