Shrine - Ruby 文件上传工具包
MIT
跨平台
Ruby
软件简介
Shrine 是提供给 Ruby 应用的文件上传工具包:简单,灵活,高性能,安全,支持直接上传。
基础示例:
require "shrine"
require "shrine/storage/file_system"
Shrine.storages[:file_system] = Shrine::Storage::FileSystem.new("uploads")
uploader = Shrine.new(:file_system)
uploaded_file = uploader.upload(File.open("avatar.jpg"))
uploaded_file #=> #<Shrine::UploadedFile>
uploaded_file.url #=> "/uploads/9260ea09d8effd.jpg"
uploaded_file.data #=>
# {
# "storage" => "file_system",
# "id" => "9260ea09d8effd.jpg",
# "metadata" => {...},
# }