0

I am using paper-clip gem so whenever i uploaded a audio file that will saved in /public/system/folder_name.. and son..

Actually it will create many folder under system folder and file present in deepest folder so problem is how can we check any file is physically exist or not under these folder hierarchy (system).

Thanks

user3436543
  • 61
  • 1
  • 9

1 Answers1

0

Check out this answer

You'll have a lot more examples there, but I think this will answer your question:

def file_dir_or_symlink_exists?(path_to_file)
  File.exist?(path_to_file) || File.symlink?(path_to_file)
end

file_dir_or_symlink_exists?('/Users')                          # => true
file_dir_or_symlink_exists?('/usr/bin/ruby')                   # => true
file_dir_or_symlink_exists?('some/bogus/path/to/a/black/hole') # => false
Community
  • 1
  • 1
Alex Falke
  • 2,178
  • 2
  • 14
  • 11