Saving SVG in Rails Active Storage - ruby-on-rails

I have a Rails application where I am storing image in the model using
has_one_attached: logo
However, when I check in the AWS console, I see that the file is saved as a text file with the contents of SVG in it. When I try to retrieve the image using a signed URL, it gives me back the content of the text file.
I want to display this image in my HTML. How can I render this SVG in my application?

because svg is text ,it will be saved as text.
for displaying it in rails app this answer should work

Related

How to view active storage blob images in Mandrill emails?

I am storing images from react to active storage. For this I have used react-quill which is a text editor and integrated it with active storage.
Now the issue is when I upload an image, I am able to store it to active storage and get back signed_id and file_name which I use to place in the src attribute of my image tag. The image src simply looks like:
/rails/active_storage/blobs/:signed_id/:filename
the signed_id and filename gets replaced however. This is working fine and I see images on the application. But I am not able to view images in mandrill emails when I send them using this format for active storage.
What am I missing here? Is there some other to alter the link to view images in email as well. TIA

How to highlight text in pdf using PdfKit

I am creating app where i need to load the pdf file from document directory and need to highlight text manually by user.
Also we need to export the updated pdf file and upload it to the server.
Is there any way to manage the same using pdfkit ?
Please share the sample code if available.
We are using the library as a reference is listed below
https://github.com/uxmstudio/UXMPDFKit
This library is using the same concept as we need but exporting the pdf is the main task we need to achieve.
In simple word we can say that user can highlight some text from the displayed pdf text and upload it to the server.

Images generated from SummerNote WYSIWYG Bootstrap broken

I am using Summer Note (http://hackerwins.github.io/summernote/) in my CMS to edit pages. For images, summer note allows you to insert images as img tag with a bunch of data (not uploaded to the server and stored in filesystem, but stored directly into database). So I am storing images within the HTML text, which is all stored in my postgres database (data type is text).
When the html is displayed on the front end, the text shows up fine but the images are broken. Is this due to the data type (text) or does there exist a better WYSIWYG bootstrap solution that allows uploading of images, as well as resizing them? Or perhaps a hack that could get around that to using uploaded images to the filesystem?
Have you tried adding .html_safe
Example:
#page.content.html_safe

How to upload x3dom files to be displayed like a gallery

I've been working with x3dom for the past month and now I wan to be able to display my work, does anyone know of an uploader where I could upload the x3dom file so that it is saved in a sort of image gallery, or is the only way to do it to keep copy pasting x3dom code to an html file and then upload thru ftp?
any variety of available upload scenarios will work
x3d is all text so you can store them as flat files and upload via ftp or if you want to have a template and dynamically viewable system you could store the x3d in a database and display that db info in a dynamically generated html file

Carrierwave to upload image

I'm using carrierwave to upload an image, this works fine up to now.
What i want to do is show the preview of the file to be submitted on the form after having selected the image.
At the moment the code I have is showing the previous image.
<%= image_tag(#book.cover_url(:thumb)) if #book.cover_url %>
how do I show the selected image rather than the image already uploaded?
You don't.
And that has nothing to do with Carrierwave but rather with the fact that the image is not yet sent to the server by your browser so no part of the Rails stack is coming into play here.
What you need is a way to access the image inside the <input type="file"> and display it to the user.
This is possible by using the FileAPI that is part of HTML5, but it's only supported in modern browsers (Webkit/Gecko), and the API is not completely finished yet so it's kind of a changing target.
I would suggest you look into tools like plupload to upload the image to the server without submitting the form and then displaying that through JavaScript.
Try http://jasny.github.io/bootstrap/javascript/#fileinput
It has a nice solution for displaying the image without the upload.

Resources