Giter VIP home page Giter VIP logo

paperclip-backblaze's Introduction

paperclip-backblaze

Build Status

The paperclip-backblaze provides a Paperclip storage adapter so that attachments can be saved to Backblaze B2 Cloud Storage API. It makes use of Winston Durand's backblaze gem to access the B2 API behind the scenes.

Backblaze B2 Cloud Storage is similar to Amazon's AWS S3 Storage, but it has a few selling points:

  1. They run their own hardware (that's open-sourced, including the schematics, and drive reports)
  2. It's $0.005/GB/month vs S3's $0.030/GB/month
  3. You actually get a free GB of bandwidth a day, so it might be nice for personal projects.

Installation

Add this line to your application's Gemfile:

gem 'paperclip-backblaze', github: 'alextsui05/paperclip-backblaze'

And then execute:

$ bundle

Usage

You should be familiar with configuring Paperclip attachments for your model. If not, please start with the Paperclip documentation here.

Configuring Backblaze storage is very similar to configuring S3 storage. Let's suppose we have a Note model with an image attachment that we would like to be backed by Backblaze storage.

First, put your credentials and bucket name in a YML file.

# config/b2.yml
account_id: 123456789abc
application_key: 0123456789abcdef0123456789abcdef0123456789
bucket: my_b2_bucket_name

Then let Paperclip know about it. You can put it in your environment config:

# config/environments/production.rb

...
config.paperclip_defaults = {
  storage: :backblaze,
  b2_credentials: YAML.load(ERB.new(File.read("#{Rails.root}/config/b2.yml")).result).with_indifferent_access
}

Now just specify the attachment in the model, and it will use your backblaze configuration:

# app/models/note.rb
class Note < ApplicationRecord
  has_attached_file :image
  ...

Currently, these are required options:

  • :storage - This should be set to :backblaze in order to use this storage adapter.

  • :b2_credentials - Should be a Hash containing required fields listend in config/b2.yml.

Contributing

This started as a proof of concept for a hobby project, so there's lots of room for improvement, and it would be great to have your help.

Bug reports and pull requests are welcome on GitHub at https://github.com/alextsui05/paperclip-backblaze. 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

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

Version Log

0.2.1

  • CI setup and code style improvements

0.2.0

  • Remove :b2_bucket option. It should now be specified in the credentials file with a bucket key.
  • Update example that doesn't pollute model with paperclip configuration

0.1.0

First release

paperclip-backblaze's People

Contributors

alextsui05 avatar r167 avatar andrewshatnyy avatar steveh avatar

Watchers

James Cloos 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.