Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download ActiveStorage attachments to tmpdir

The objective is to download an attached file to tempdir for subsequent usage. The documentation says to use ActiveStorage::Blob#open which seems simple enough.

I'm getting errors so please explain what I'm doing wrong:

  1. Calling @flower.photo.open results in NoMethodError (private method 'open' called for #<ActiveStorage::Attached::One:0x00007f9780625100>)
  2. Calling @flower.photo.blob.open` results in NoMethodError (private method 'open' called for #<ActiveStorage::Blob:0x00007f9780615c50>)

Examining the source code I'm not sure why I'm getting the private method error.

like image 501
GuyWrySmile Avatar asked Jun 15 '18 17:06

GuyWrySmile


1 Answers

That method isn't released until rails 6 next year.

There’s a similar SO question here with more info and a recommendation.

like image 178
GuyWrySmile Avatar answered Nov 15 '22 01:11

GuyWrySmile