Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嗨,我想知道如何在 ruby 中创建一个临时文件图像(png),因为 tempfile 只会为您提供一个随机文件名,但它没有扩展文件。
检查文档!
# Use the Array form to enforce an extension in the filename: file = Tempfile.new(['hello', '.jpg']) file.path # => something like: "/tmp/foo2843-8392-92849382--0.jpg"