GuyWrySmile
GuyWrySmile

Reputation: 140

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.

Upvotes: 7

Views: 2391

Answers (1)

GuyWrySmile
GuyWrySmile

Reputation: 140

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

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

Upvotes: 5

Related Questions