I am currently creating a web page with Rails.

I want to save the user's posted images in the "privacy" folder in the same hierarchy, not in the public folder that anyone can see, and display it on the page.

Because webpacker is used, images under app/assets/images and public are described and displayed as follows.
<% = image_pack_tag 'xxxxx.png'%>
How can I display this image in the "privacy" folder at the same level as the public folder?

I don't know how to check it, but I didn't understand it.
It can be a useful site, so I would appreciate it if you could teach me how to do it.
Thank you.

Amazon Linux release 2 (Karoo)
Rails 5.2.3
Ruby version: 2.6.1

  • Answer # 1


    I want to save it in the "privacy" folder on the same level and display it on the page.

    Other than thepublicfolder cannot be accessed from the other side of the web, it is usuallynot displayable.

    Make something that returns image data as a Rails controller and link it to it

    Encode image file into Data URI and return the result

    You have to take a technique like


Related articles