GithubHelp home page GithubHelp logo

gerbal / carrierwave-google-storage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from carrierwaveuploader/carrierwave-google-storage

0.0 3.0 0.0 72 KB

Carrierwave storage adapter that supports Google Cloud Storage and is based on gcloud library from Google

License: MIT License

Ruby 99.21% Shell 0.79%

carrierwave-google-storage's Introduction

Carrierwave Google Storage

Build Status Code Climate Gem Version

Use the official google-cloud gem by Google for Google Cloud Storage, instead of Fog.

  • No need to activate Interoperable Access on your project.
  • Rely on Google's preferred authentication mechanism. ie: Service Accounts.

Installation

Add this line to your application's Gemfile:

gem 'carrierwave-google-storage'

Rails Compatibility:

  • Rails 4 and 5.

Usage

In config/initializers/carrierwave.rb add the following initialization code:

CarrierWave.configure do |config|
  config.storage                             = :gcloud
  config.gcloud_bucket                       = 'your-bucket-name'
  config.gcloud_bucket_is_public             = true
  config.gcloud_authenticated_url_expiration = 600
  
  config.gcloud_attributes = {
    expires: 600
  }
  
  config.gcloud_credentials = {
    gcloud_project: 'gcp-project-name',
    gcloud_keyfile: 'path-to-gcp-keyfile.json'
  }
end

Then, in your Uploader classes:

class FileUploader < CarrierWave::Uploader::Base
   storage :gcloud
end

How to get the Keyfile?

To generate a new keyfile, perform the following steps:

  • Go to Cloud Console > API Manager > Credentials
  • Click Create Credentials > Service Account Key
  • Service Account > New Service Account
  • Give any name for "Service Account Name"
  • Set Key type to JSON
  • Click "Create"

Here's a quick GIF for those who are visual like myself:

Contributing

Environment Variables and such

You should have access to a Google Cloud Platform account, as you'll need the keyfile and a project ID in order to contribute to the development of this gem. You'll need the the following files:

  • .gcp-keyfile.json (sample file provided: .gcp-keyfile.sample.json)
  • .env (sample file provided: .env.sample)

If you have any questions, please feel free to open up issues and/or PR's. Contributions are welcomed.

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

You get extra attention, if your PR includes specs/tests.

  • Fork or clone the project.
  • Create your feature branch ($ git checkout -b my-new-feature)
  • Install the dependencies by doing: $ bundle install in the project directory.
  • Add your bug fixes or new feature code.
  • New features should include new specs/tests.
  • Bug fixes should ideally include exposing specs/tests.
  • Commit your changes ($ git commit -am 'Add some feature')
  • Push to the branch ($ git push origin my-new-feature)
  • Open your Pull Request!

License

Copyright (c) 2016 Jasdeep Singh (Metaware Labs Inc)

The gem is available as open source under the terms of the MIT License.

carrierwave-google-storage's People

Contributors

jasdeepsingh avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.