MyUploader.upload vs ImageUploader::Attachment (symbol is not a valid IO object))

The Getting Started section of the (excellent) docs suggest using include ImageUploader::Attachment(:image) in the model if you don’t want to bother with processing.

Further down, there’s a section about MyUploader.upload(). Because I would like to process the images and change the s3 upload directory structure, I am using this. However, this method does not take symbols.

Doing this: ImageUploader.upload(:image, :store) results in an error that says this: :image is not a valid IO object (it doesn't respond to #read, #eof?, #rewind, #close) (Shrine::InvalidFile)

How do I get a valid IO object?

Hi there

Welcome to the forums.

Please forgive me if you are already aware of the following:

Changing the upload directory Structure

If you want to change the directory structure - there is a plugin available for that: so you literally don’t have to do much to customise the file location. The plugin will also give you access tot he IO object (if you need it).

Processing - How do I get a valid IO object?

I am by no means an expert on Shrine here. And I am assuming that your users will be uploading images on the client side? If that’s the case then you probably don’t need to use the ImageUploader.upload method directly. Just use the plugins available: and then they should give you access to the IO object.

This provides a general overview of on the fly processing.

If there are further questions, perhaps post again, and someone should be able to help out.

1 Like