Skip to content
/ shrine Public
forked from shrinerb/shrine

File Attachment toolkit for Ruby applications

License

Notifications You must be signed in to change notification settings

sjaq/shrine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Uploadie

Uploadie is my attempt at solving file uploads in Ruby.

Installation

Add the gem to your Gemfile:

gem 'uploadie'

Usage

require "uploadie"
require "uploadie/storage/file_system"
require "tmpdir"

Uploadie.storages = {
  temporary: Uploadie::Storage::FileSystem.new(Dir.tmpdir),
  permanent: Uploadie::Storage::FileSystem.new("uploads", root: "public"),
}

cache = Uploadie.new(:temporary)
store = Uploadie.new(:permanent)

cached_file = cache.upload(File.open("path/to/image.jpg"))
cached_file      #=> Uploadie::File
cached_file.data #=> {"storage" => "temporary", "id" => "avatar/kr92l23nf/image.jpg", "metadata" => {}}
cached_file.url  #=> "/var/folders/k7/6zx6dx6x7ys3rv3srh0nyfj00000gn/T/avatar/kr92l23nf/image.jpg"

stored_file = store.upload(cached_file)
stored_file      #=> Uploadie::File
stored_file.data #=> {"storage" => "permanent", "id" => "avatar/23alsd05l/image.jpg", "metadata" => {}}
stored_file.url  #=> "/uploads/avatar/23alsd05l/image.jpg"

Code of Conduct

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.

Thanks

TODO: Heavily inspired by Refile and Roda

License

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

About

File Attachment toolkit for Ruby applications

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 97.8%
  • HTML 1.3%
  • CSS 0.9%