StringIO to Tempfile?

So I'm wondering is there a way to create a Tempfile from a StringIO? I
have looked at the docs and been unable to find out how to create a
Tempfile from a blob.

It works like File.

TempFile.new do |f|
  f.write file.to_s
end