LoginSignup
0
0

More than 5 years have passed since last update.

衝突しないユニークなファイル名を取得する方法

Posted at

Tempfile みたいにFileを取得したい場合ではなく、ファイル名を取得したい場合の方法。

base_name = "image"  # 必要に応じてディレクトリパスも含める
ext_name = "jpg"
Dir::Tmpname.make_tmpname(base_name, ext_name) =>  "image20160902-29100-1xxd3n7-jpg"
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0