관리-도구
편집 파일: M000060.html
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>new (Rack::Multipart::UploadedFile)</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" /> </head> <body class="standalone-code"> <pre><span class="ruby-comment cmt"># File lib/rack/multipart/uploaded_file.rb, line 10</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">content_type</span> = <span class="ruby-value str">"text/plain"</span>, <span class="ruby-identifier">binary</span> = <span class="ruby-keyword kw">false</span>) <span class="ruby-identifier">raise</span> <span class="ruby-node">"#{path} file does not exist"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">path</span>) <span class="ruby-ivar">@content_type</span> = <span class="ruby-identifier">content_type</span> <span class="ruby-ivar">@original_filename</span> = <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">path</span>) <span class="ruby-ivar">@tempfile</span> = <span class="ruby-constant">Tempfile</span>.<span class="ruby-identifier">new</span>([<span class="ruby-ivar">@original_filename</span>, <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-identifier">path</span>)]) <span class="ruby-ivar">@tempfile</span>.<span class="ruby-identifier">set_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">BINARY</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@tempfile</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:set_encoding</span>) <span class="ruby-ivar">@tempfile</span>.<span class="ruby-identifier">binmode</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">binary</span> <span class="ruby-constant">FileUtils</span>.<span class="ruby-identifier">copy_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-ivar">@tempfile</span>.<span class="ruby-identifier">path</span>) <span class="ruby-keyword kw">end</span></pre> </body> </html>