Coder Social home page Coder Social logo

Comments (6)

janko avatar janko commented on May 16, 2024

What changed is that this functionality got extracted into a separate parsed_json plugin. The reason for this is that I intended to make a plugin for enabling multiple files uploads in the same column, and having this functionality in the base made things more complicated, so I thought it would be more easily managed.

I initially thought that this would only be required in the case where a JSON string is submitted in the form, and the web framework parses that JSON. However, I see that this use case is completely valid, and I also used this functionality in the existing app (which I didn't update with the 1.0 release). Even though in the meanwhile I've put the plugin for multiple files on hold (I find it too difficult to implement properly, and not important enough at the moment), I would still like to have this path open.

I'm not sure if it was the right decision to move this into a plugin, I will see if adding it back would still leave the path open for the potential multiple files plugin. Otherwise I will update the documentation to be explicit about accepting only JSON strings (and the example app as well).

from shrine.

Chocksy avatar Chocksy commented on May 16, 2024

@janko-m ok ignore this it seems because of me setting avatar_data column with some json/hash string and then trying to set @user.avatar again was giving me that error. I'll close this.

from shrine.

vcavallo avatar vcavallo commented on May 16, 2024

Hello.

I'm having the same error.

Shrine::InvalidFile (<ActionController::Parameters {"id"=>"988c14e239761adbec83c00f91ce0e42.png", "storage"=>"cache", "metadata"=><ActionController::Parameters {"filename"=>"tiny.png", "size"=>148, "mime_type"=>"image/png", "width"=>3, "height"=>3} permitted: true>} permitted: true> is not a valid IO object (it doesn't respond to         #read, #eof?, #rewind, #close)):

As far as I can tell (this is my first run-in with Shrine, trying to replace the half-baked ActiveStorage) I'm doing fairly normal stuff implementing a direct upload solution with S3. I'm expecting this json reference to the cached version (which is getting uploaded to S3 just fine) to trigger the full save / promote behavior, but instead I'm getting this error.

Is the issue here actually the ActionController::Parameters bit getting in the way?

from shrine.

vcavallo avatar vcavallo commented on May 16, 2024

Fixed by calling .to_json on the params hash in the controller.

from shrine.

jrochkind avatar jrochkind commented on May 16, 2024

@vcavallo Alternatively, I believe you just need to add the parsed_json plugin to shrine, such as with Shrine.plugin :parsed_json.

Or, sometimes instead of sending these things back as separate params, people send them to Rails as a serialized JSON string in the first place -- which is what most of the shrine examples show -- in which case it would just work.

Any of those approaches should be fine.

from shrine.

vcavallo avatar vcavallo commented on May 16, 2024

from shrine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.