通过rails应用程序从服务中暴露文件 [英] exposing files from a service through a rails application
问题描述
-C
send_file @ file.path,:x_sendfile => true
at apidock 。
这允许您使用rails身份验证从文件系统提供文件,但服务实际文件将会通过您的apache / lighttd模块,并不会绑定一个rails进程。
只要获得MS Office文档,您可能希望该服务调用不同的操作,它告诉你的rails应用来下载新的文档。
class MyController< ApplicationController
def get_new_document
除非params [:file_path] .nil?或params [:server_uri] .nil?
@new_document = Net :: Http.get(params [:server_uri],params [:file_path])
@ new_document.save#保存到文件系统
end
end
end
I have a rails application that generates open office files, and I have a service at another location that will convert these open office files to microsoft office files. I'd like to have a controller action that will send the open office file to the converter, then serve the returned microsoft office file to the user. how could I do this?
-C
Check out
send_file @file.path, :x_sendfile => true
at apidock.
This allows you to serve files from the filesystem with rails authentication, but serving the actual file will go through your apache/lighttd module and won't tie up a rails process.
As far as getting the MS office document back, you will probably want the service to call a different action, which tells your rails app to download the new document.
class MyController < ApplicationController
def get_new_document
unless params[:file_path].nil? or params[:server_uri].nil?
@new_document = Net::Http.get(params[:server_uri], params[:file_path])
@new_document.save # save to filesystem
end
end
end
这篇关于通过rails应用程序从服务中暴露文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!