Permalink
Browse files

closed the dangling open file

  • Loading branch information...
1 parent 8d559f6 commit 45c74f18db97e0d3dded792d5ea637b0f81d4de4 Jeffrey Damick committed Jun 18, 2009
Showing with 8 additions and 7 deletions.
  1. +8 −7 lib/inline_attachment.rb
@@ -65,14 +65,15 @@ def path_to_image_with_inline_attachment(source)
basename = File.basename(file_path)
ext = basename.split('.').last
cid = Time.now.to_f.to_s + "#{basename}@inline_attachment"
- file = File.open(file_path, 'rb')
- @part_container.inline_attachment(:content_type => "image/#{ext}",
- :body => file.read,
- :filename => basename,
- :cid => "<#{cid}>",
- :disposition => "inline")
-
+ File.open(file_path, 'rb') do |file|
+ @part_container.inline_attachment(:content_type => "image/#{ext}",
+ :body => file.read,
+ :filename => basename,
+ :cid => "<#{cid}>",
+ :disposition => "inline")
+ end
+
return "cid:#{cid}"
end
end

0 comments on commit 45c74f1

Please sign in to comment.