[英]Handling Paperclip folder and file permissions using Ruby on Rails
[英]Change permissions of file in Ruby
我的代碼如下
def initialise
@doc_path =nil
@user= nil
end
def execute
oscmd = Common::OsCmd.new
oscmd.log = @log.info("message")
File.open("#{@doc_path}/new.doc","w") do |f|
f.puts "/#{@name} /people/* "
File.chmod(0777,"#{@doc_path}/new.doc")
FileUtils.chown("#{@user}, #{@user}, #{@doc_path}")
end
end
所以我的代碼通過其他配置文件中的標記化來執行,其中它具有doc_path
, user
值
我的代碼在chown
和chmod
上給出了錯誤
通過在chown中傳遞有效用戶來嘗試以下操作:
def self.execute
oscmd = Common::OsCmd.new
oscmd.log = @log.info("message")
File.open("#{@doc_path}/new.doc","w") do |f|
f.puts "/#{@name} /people/* "
File.chmod(0777,"#{@doc_path}/new.doc")
FileUtils.chown 'vinod', 'vinod', "#{@doc_path}"
end #-- do ends here
end #-- def ends here
chown用法:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.