owaiswiz / devitary

Simple free static image hosting using firebase - Demo: https://devitary.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

devitary

A simple rails application with an API and a simple web interface to upload & host static files (Images, Fonts) or any other files with Google Firebase for free (refer limits).

Deploying your own

  1. Create a firebase project - Firebase Console.

  2. Create a default storage bucket

    • Click Develop > Storage > Get Started > Next > Choose Location > Done
  3. Download the credentials json file with private key from firebase console.

    • Click Settings Icon > Project Settings > Service Accounts > Generate new private key > Generate key
  4. Clone this repository

    git clone https://github.com/owaiswiz/devitary.git
    
  5. Set the environment variable STORAGE_CREDENTIALS with the content of the downloaded json file

  6. Run the server using rails s or deploy how you would deploy any other rails app

Using the API

Create a post request to /upload with the file in the multipart form data body

Example

response = HTTParty.post(
	'http://YOURHOSTEDIPORURL/upload', 
	body: {
		file: File.open("/home/owaiswiz/Downloads/SashaSloan.png")
	}
)
json = JSON.parse(response.body)
puts json["url"]  # => "https://storage.googleapis.com/devitary-image-host.appspot.com/15828387941719051810-c.png" 

About

Simple free static image hosting using firebase - Demo: https://devitary.herokuapp.com/


Languages

Language:Ruby 66.4%Language:HTML 24.0%Language:JavaScript 7.4%Language:CSS 2.3%