[英]Rails 4: Issue Sending .txt files from local machine to Windows Share
I'm currently creating .csv files from a SQL view and writing to 我目前正在从SQL视图创建.csv文件,并写入
#{Rails.root}/public/
which works no problem. 没问题。 In addition, I need to write these generated files to a Windows share in the form of:
另外,我需要将这些生成的文件以以下形式写入Windows共享:
\\\\NAME-APP.enterprise.company.com\\Files
I've tried Net::SCP.upload
, Net::SFTP.start
, FileUtils
, rsync
, and even Dir.entries('share url here
)` just to see if I can see anything in the folder, which generally results in 我试过
Net::SCP.upload
, Net::SFTP.start
, FileUtils
, rsync
,甚至Dir.entries('share url here
)`只是为了看看我能看到的文件夹,这通常会导致什么
No such file or directory @ dir_initialize
I can map my local computer to the Windows share point, in the form of: 我可以将本地计算机以以下形式映射到Windows共享点:
smb://NAME-APP.enterprise.company.com/Files
but manually dragging and dropping to there isn't an acceptable solution in this case. 但是在这种情况下,手动拖放到那里是不可接受的解决方案。
Feel like I've hit a wall and may be overlooking something. 感觉就像我撞墙了,可能正在俯瞰某些事物。 Have stumbled across this post but to no avail: How do I address a UNC path in Ruby on Windows?
偶然发现了这篇文章,但无济于事: 如何在Windows上的Ruby中解决UNC路径?
Any advice on this is greatly appreciated. 非常感谢对此的任何建议。
Edit: 编辑:
FileUtils.cp_r('/Volumes/Macintosh HD/Users/davidpardy/development/ror/sbb/oct31week/1a/FST-Export/public/1538791_new.txt', '\\\\\\\\NAME-APP\\\\Files')
doesn't return an error, but doesn't upload the .txt file to Files. 不会返回错误,但不会将.txt文件上传到“文件”。
The solution is not to use FileUtils.cp_r(source_file, 'smb://...')
because smb://...
only represents the server address, not the mount folder on your filesystem. 解决方案是不使用
FileUtils.cp_r(source_file, 'smb://...')
因为smb://...
仅代表服务器地址,而不代表文件系统上的安装文件夹。
In the terminal, run the mount
command to find the path of the mount folder, which is what you'll use in ruby, eg, FileUtils.cp_r(source_file, '/Volumes/mount_folder_here...')
. 在终端中,运行
mount
命令以查找mount文件夹的路径,这是您将在ruby中使用的路径,例如FileUtils.cp_r(source_file, '/Volumes/mount_folder_here...')
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.