Ruby 图像上传框架 Ruby Dragonfly

码农软件 · 软件分类 · 文件上传组件 · 2019-03-30 08:27:10

软件介绍

Dragonfly 是一个 Ruby gem 用于动态处理 Rails、Sinatra 等框架的图像上传。

示例代码:

如果你想生成缩略图:

class User < ActiveRecord::Base  # model
  dragonfly_accessor :photo
end

<%= image_tag @user.photo.thumb('300x200#')  # view  %>

在 Sinatra 下生成文本图像

get "/:text" do |text|
  Dragonfly.app.generate(:text, text, "font-size" => 32).to_response(env)
end

生成附件

wav = Dragonfly.app.fetch_url("http://free.music/lard.wav")  # GET from t'interwebs
mp3 = wav.to_mp3  # to_mp3 is a custom processor
uid = mp3.store   # store in the configured datastore, e.g. S3

url = Dragonfly.app.remote_url_for(uid)  # ===> http://s3.amazon.com/my-stuff/lard.mp3

本文地址:https://www.codercto.com/soft/d/2461.html

The Hard Thing About Hard Things

The Hard Thing About Hard Things

Ben Horowitz / HarperBusiness / 2014-3-4 / USD 29.99

Ben Horowitz, cofounder of Andreessen Horowitz and one of Silicon Valley's most respected and experienced entrepreneurs, offers essential advice on building and running a startup—practical wisdom for ......一起来看看 《The Hard Thing About Hard Things》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

SHA 加密
SHA 加密

SHA 加密工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具