15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/hydra/derivatives/extract_metadata.rb', line 15
def to_tempfile &block
return unless has_content?
list_of_extensions = MIME::Types[mimeType].first.extensions
extension = ".#{list_of_extensions.first}" if list_of_extensions
f = Tempfile.new(["#{pid}-#{dsVersionID}", extension])
f.binmode
if content.respond_to? :read
f.write(content.read)
else
f.write(content)
end
f.close
content.rewind if content.respond_to? :rewind
yield(f)
f.unlink
end
|