Skip to content

Commit

Permalink
closed the dangling open file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrey Damick committed Jun 18, 2009
1 parent 8d559f6 commit 45c74f1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/inline_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 45c74f1

Please sign in to comment.