# PaperClip: Attach files through script/console

**URL:** <https://www.ruby-forum.com/t/paperclip-attach-files-through-script-console/182050>\
**Category:** Ruby\
**Created:** [January 21, 2010, 11:52pm UTC](https://www.ruby-forum.com/t/paperclip-attach-files-through-script-console/182050 "2010-01-21T23:52:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ndorphine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@ndorphine](https://www.ruby-forum.com/u/ndorphine)\
**Post date:** [January 21, 2010, 11:52pm UTC](https://www.ruby-forum.com/t/paperclip-attach-files-through-script-console/182050/1 "2010-01-21T23:52:25Z")

</div>

I’m wondering is it possible to attach a file through script/console?

---

<div class="post-metadata">

**Author:** ![ndorphine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@ndorphine](https://www.ruby-forum.com/u/ndorphine)\
**Post date:** [January 22, 2010, 12:14am UTC](https://www.ruby-forum.com/t/paperclip-attach-files-through-script-console/182050/2 "2010-01-22T00:14:22Z")

</div>

Worked this out for myself in a round about way, I used rest\_client and  
made a post locally, if anyone knows of a “neater” way I’d like to know

John O’gara wrote:

> I’m wondering is it possible to attach a file through script/console?

---

<div class="post-metadata">

**Author:** ![ndorphine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@ndorphine](https://www.ruby-forum.com/u/ndorphine)\
**Post date:** [January 22, 2010, 3:21am UTC](https://www.ruby-forum.com/t/paperclip-attach-files-through-script-console/182050/3 "2010-01-22T03:21:02Z")

</div>

On 21 ene, 19:53, John O’gara [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m wondering is it possible to attach a file through script/console?

image = Image.new(:storage =\> File.open(‘/path/to/my/image.png’, rb))

Where:

Image is your model  
storage is your paperclip definition of has\_attachment.

HTH,

---

<div class="post-metadata">

**Author:** ![ndorphine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@ndorphine](https://www.ruby-forum.com/u/ndorphine)\
**Post date:** [January 22, 2010, 10:23am UTC](https://www.ruby-forum.com/t/paperclip-attach-files-through-script-console/182050/4 "2010-01-22T10:23:28Z")

</div>

Thanks Luis, thats much neater.  
Luis L. wrote:

> image = Image.new(:storage =\> File.open(’/path/to/my/image.png’, rb))
> 
> Where:
> 
> Image is your model  
> storage is your paperclip definition of has\_attachment.
> 
> HTH,
