How to transfer an image object in Sinatra

I uploaded images to mongoDB using GridFS. I want to get an image from db and display it in a browser. How to do it with Sinatra and HAML.

+3
source share
1 answer

This Sinatra application uses the old GridStore API, but the principle still applies. Create a separate URL for the images, set the content type, and call #read in the Grid method:

http://github.com/banker/mongodb_examples/blob/master/tweets/sinatra_tweets.rb

+2
source

Source: https://habr.com/ru/post/1740756/


All Articles