Giter Site home page Giter Site logo

carrierwave-box's Introduction

Carrierwave::Box

Now you can use box.net/box.com with Carrierwave.

Easy to config, easy use, and helpful.

You can use box.net/box.com to store image (i was check, it working with rails to show image in view).

Gem will auto generater access token, don't worry about access token. :D

Installation

Add this line to your application's Gemfile:

gem 'carrierwave-box'

And then execute:

$ bundle

Or install it yourself as:

$ gem install carrierwave-box

##Note:

In your developer web view, you need to set return uri to: http://localhost

Usage

So simple:

  • Config for carrierwave:

        CarrierWave.configure do |config|
          config.box_client_id            = ENV['BOX_CLIENT_ID']
          config.box_client_secret        = ENV['BOX_CLIENT_SECRET']
          
          config.jwt_private_key_path     = ENV['JWT_PRIVATE_KEY_PATH'] # if using box enterprise or nil
          config.jwt_private_key_password = ENV['JWT_PRIVATE_KEY_PASSWORD']
          config.box_enterprise_id        = ENV['BOX_ENTERPRISE_ID']
          
          config.box_email                = 'your_box_email' # if using simple acaunt
          config.box_password             = 'your_box_password'
          
          config.box_access_type          = "box"
          config.cache_dir                = "#{Rails.root}/tmp/uploads"
          config.enable_processing        = true
          config.storage                  = :box
        end       

Special of this gem:

- Gem will auto generater access token.

- No need time to get access token.

- Why box.net/box.com is so difficult to do gem: Access token is only valid in 60 minutes. :(

- With gem you can easy to use, but notice time to upload will be longer. (it depend your internet and your vps/computer).
  • How to integate:

      class FileUpload < ActiveRecord::Base
        # Upload picture
        mount_uploader :file_name, AbcUploader
      end
      class AbcUploader < CarrierWave::Uploader::Base
        # Include RMagick or MiniMagick support:
        # include CarrierWave::RMagick
        # include CarrierWave::MiniMagick
        # Choose what kind of storage to use for this uploader:
        storage :box
      end
  • To show image in view with Rails

    EX:

    = image_tag FileUpload.last.file_name.url

TODO

  • Test, test and test...

  • Improvement speed.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/thiensubs/carrierwave-box. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

Copyright (c) 2015 thiensubs - Vo Tien An The gem is available as open source under the terms of the MIT License.

carrierwave-box's People

Contributors

acv-anvt avatar rudskikhivan avatar kostyakch avatar thiensubs avatar

Stargazers

Peter Boling avatar

Watchers

Peter Boling 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.