2017-02-15 51 views
0

在Ubuntu上,回形針文件上傳與內置文件命令配合使用。在Windows上,我都在PATH變量中安裝了Ruby Devkit或file.exe:這些都沒有幫助!我得到:在Windows上回形針在Ruby Devkit中使用「file」命令,但是在ArticlesController中創建錯誤「Errno :: EEXIST#

File exists @ sys_fail2 - C:/Users/Lap127/AppData/Local/Temp/3e26e8e7aa5f147d0c6c7ae71efc007220170215-7312-1bv14wq.txt 
Extracted source (around line #24): 

def create 
    @article = Article.new(article_params) #line 24 here 

    if @article.save 
    redirect_to @article 

如何上傳與Windows回形針附件沒有得到錯誤,該文件已經存在?

回答

0

之前遇到過類似的問題,它花了一些搜索,但這裏的問題是在Windows上的tempfiles和Ruby的問題。

C:\<path_to_ruby_file>\lib\ruby\<version>\tempfile.rb

在此基礎上一篇:https://www.ruby-forum.com/topic/187311

我們的團隊能夠發現問題。

雖然他們有一個解決方案,我們最終編寫自己的。 你想(〜204線):

def unlink 
    #----ADDED THIS LINE---# 
    return if @unlinked 
    #-----END ADDED LINE----# 
    begin 
    File.unlink(@tmpfile.path) 
    rescue Errno::ENOENT 
    rescue Errno::EACCES 
    # may not be able to unlink on Windows; just ignore 
    return 
    end 
    ObjectSpace.undefine_finalizer(self) 
    @unlinked = true 
end 
alias delete unlink 

如果您仍然收到此錯誤,讓我知道!此外,如果您可以檢查tempfile的內容是否您期望的內容,那可能很有用。

相關問題