Re: How do i create an UploadedFile from base64 encoded pdf string without activerecord in rails

575 views
Skip to first unread message
Message has been deleted

Janko Marohnić

unread,
Mar 16, 2018, 12:18:27 PM3/16/18
to ckp...@gmail.com, Shrine
You can create an IO object from a data URI using the Shrine.data_uri method:

Shrine.plugin :data_uri

io = Shrine.data_uri(data_uri_string)

You can then use this IO object for attaching like any other File object, or for whatever else you need. Is this what you wanted?

Kind regards,
Janko

On Fri, Mar 16, 2018 at 5:15 PM, <ckp...@gmail.com> wrote:
I have a base64 pdf string i would like to create an UploadedFile class from it just like you get when using active record. I have the data uri plugin but  i dont want to use activerecord. How do i go about it.

--
You received this message because you are subscribed to the Google Groups "Shrine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-shrine+unsubscribe@googlegroups.com.
To post to this group, send email to ruby-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-shrine/9c6498ce-7296-4bed-937c-655b64c4172f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Janko Marohnić

unread,
Mar 16, 2018, 12:19:44 PM3/16/18
to ckp...@gmail.com, Shrine
If you have a pure base64 string, you would need to convert it to a data URI first:

Shrine.data_uri("data:base64,#{base64}")

Kind regards,
Janko
Reply all
Reply to author
Forward
Message has been deleted
0 new messages