LoginSignup
3
3

More than 5 years have passed since last update.

CarrierWaveのファイル読み書きをもう少し詳しく。

Posted at
uploader = AvatarUploader.new
my_file = open('my_file.txt')
uploader.store!(my_file) #carrierwaveのstore_dirに保存される
my_file2 = open('my_file2.txt')
uploader.store!(my_file2) #carrierwaveのstore_dirに保存される

uploader.retrieve_from_store!('my_file.txt') #保存されたファイルを表に持ってくる
puts uploader.file.read                      #表に持ってきたファイル(my_file.txt)を読み出し

uploader.retrieve_from_store!('my_file2.txt') #保存されたファイルを表に持ってくる
puts uploader.file.read                       #表に持ってきたファイル(my_file2.txt)を読み出し
3
3
0

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
3
3