Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Tempfile plugins causes Shrine::Error file must be opened #537

@vanboom

Description

@vanboom

Brief Description

I have a simple file attachment uploader that stores files in GCS storage. On my model before_save callback I store the size of the image file in my database by accessing:

class Comment
   before_save :store_file_size
   include CommentUploader::Attachment(:file)

   def store_file_size
      file.size
   end
end

Expected behavior

The tempfile plugin should not affect normal behavior that works fine when the tempfile plugin is not used.

Actual behavior

When I add the tempfile plugin, I get a Shrine::Error - uploaded file must be opened.
Calling file.open prior to file.size or file.dimensions works. The tempfile plugin is forcing a requirement to call file.open

System configuration

Ruby version: 2.5.0

Shrine version: 3.3.0

Thanks for an amazing gem and for your consideration of this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions