I am learning ruby on rails. I am developing a rails 5 application. I don't want to use amazon s3 service for containing my assets files. I want to use github for serving my assets files as like CDN.
But I am facing a problem, I have dynamic file and image upload system.
So therefore, When I will upload my files and images, all files and images will be uploaded in a github repository (assume, I have a git repo named busket
; so, all images and files will be uploaded in busket
repo from my server and will serve all assets from rails application).
So, how can I make github as like CDN ? Please help me about this issue.
1.) Encode image to base 64 ref: http://ruby-doc.org/stdlib-2.2.0/libdoc/base64/rdoc/Base64.html
2.) Make API call to github
ref: https://developer.github.com/v3/repos/contents/#create-a-file
This will upload and return the url of your stored image within github, store that in your database.
Although you stated you didn't want to use S3, the paperclip gem makes it very streamlined.