- 浏览: 59069 次
- 性别:
- 来自: 苏州
最新评论
-
se7en8974:
有效。顶一个
老外的lovcombo 使用注意点 -
yekki:
rake rails:freeze:gem与rake rail ...
rake rails:freeze -
tianzhihua:
把你的错误贴上来吧
Struts2 Map 映射 -
myoldman:
我记得java里面integer的最大数值为214748364 ...
Struts2 Map 映射
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.
C:\Documents and Settings\sunchaohui>cd D:\radrails-0.7.2-win32\workspace\mm
C:\Documents and Settings\sunchaohui>d:
D:\radrails-0.7.2-win32\workspace\mm>ruby script/plugin install attachment_fu
svn: No repository found in 'svn://rubyforge.org/var/svn/cartographer/plugins'
+ ./CHANGELOG
+ ./README
+ ./Rakefile
+ ./amazon_s3.yml.tpl
+ ./init.rb
+ ./install.rb
+ ./lib/geometry.rb
+ ./lib/technoweenie/attachment_fu/backends/db_file_backend.rb
+ ./lib/technoweenie/attachment_fu/backends/file_system_backend.rb
+ ./lib/technoweenie/attachment_fu/backends/s3_backend.rb
+ ./lib/technoweenie/attachment_fu/processors/core_image_processor.rb
+ ./lib/technoweenie/attachment_fu/processors/gd2_processor.rb
+ ./lib/technoweenie/attachment_fu/processors/image_science_processor.rb
+ ./lib/technoweenie/attachment_fu/processors/mini_magick_processor.rb
+ ./lib/technoweenie/attachment_fu/processors/rmagick_processor.rb
+ ./lib/technoweenie/attachment_fu.rb
+ ./test/backends/db_file_test.rb
+ ./test/backends/file_system_test.rb
+ ./test/backends/remote/s3_test.rb
+ ./test/base_attachment_tests.rb
+ ./test/basic_test.rb
+ ./test/database.yml
+ ./test/extra_attachment_test.rb
+ ./test/fixtures/attachment.rb
+ ./test/fixtures/files/fake/rails.png
+ ./test/fixtures/files/foo.txt
+ ./test/fixtures/files/rails.png
+ ./test/geometry_test.rb
+ ./test/processors/core_image_test.rb
+ ./test/processors/gd2_test.rb
+ ./test/processors/image_science_test.rb
+ ./test/processors/mini_magick_test.rb
+ ./test/processors/rmagick_test.rb
+ ./test/schema.rb
+ ./test/test_helper.rb
+ ./test/validation_test.rb
+ ./vendor/red_artisan/core_image/filters/color.rb
+ ./vendor/red_artisan/core_image/filters/effects.rb
+ ./vendor/red_artisan/core_image/filters/perspective.rb
+ ./vendor/red_artisan/core_image/filters/quality.rb
+ ./vendor/red_artisan/core_image/filters/scale.rb
+ ./vendor/red_artisan/core_image/filters/watermark.rb
+ ./vendor/red_artisan/core_image/processor.rb
attachment-fu
=============
attachment_fu is a plugin by Rick Olson (aka technoweenie <http://techno-weenie.
net>) and is the successor to acts_as_attachment. To get a basic run-through of
its capabilities, check out Mike Clark's tutorial <http://clarkware.com/cgi/blo
sxom/2007/02/24#FileUploadFu>.
attachment_fu functionality
===========================
attachment_fu facilitates file uploads in Ruby on Rails. There are a few storag
e options for the actual file data, but the plugin always at a minimum stores me
tadata for each file in the database.
There are three storage options for files uploaded through attachment_fu:
File system
Database file
Amazon S3
Each method of storage many options associated with it that will be covered in t
he following section. Something to note, however, is that the Amazon S3 storage
requires you to modify config/amazon_s3.yml and the Database file storage requi
res an extra table.
attachment_fu models
====================
For all three of these storage options a table of metadata is required. This ta
ble will contain information about the file (hence the 'meta') and its location.
This table has no restrictions on naming, unlike the extra table required for
database storage, which must have a table name of db_files (and by convention a
model of DbFile).
In the model there are two methods made available by this plugins: has_attachmen
t and validates_as_attachment.
has_attachment(options = {})
This method accepts the options in a hash:
:content_type # Allowed content types.
# Allows all by default. Use :image to allow all standard
image types.
:min_size # Minimum size allowed.
# 1 byte is the default.
:max_size # Maximum size allowed.
# 1.megabyte is the default.
:size # Range of sizes allowed.
# (1..1.megabyte) is the default. This overrides the :min
_size and :max_size options.
:resize_to # Used by RMagick to resize images.
# Pass either an array of width/height, or a geometry stri
ng.
:thumbnails # Specifies a set of thumbnails to generate.
# This accepts a hash of filename suffixes and RMagick res
izing options.
# This option need only be included if you want thumbnaili
ng.
:thumbnail_class # Set which model class to use for thumbnails.
# This current attachment class is used by default.
:path_prefix # path to store the uploaded files.
# Uses public/#{table_name} by default for the filesystem,
and just #{table_name} for the S3 backend.
# Setting this sets the :storage to :file_system.
:storage # Specifies the storage system to use..
# Defaults to :db_file. Options are :file_system, :db_fil
e, and :s3.
:processor # Sets the image processor to use for resizing of the atta
ched image.
# Options include ImageScience, Rmagick, and MiniMagick.
Default is whatever is installed.
Examples:
has_attachment :max_size => 1.kilobyte
has_attachment :size => 1.megabyte..2.megabytes
has_attachment :content_type => 'application/pdf'
has_attachment :content_type => ['application/pdf', 'application/msword', 't
ext/plain']
has_attachment :content_type => :image, :resize_to => [50,50]
has_attachment :content_type => ['application/pdf', :image], :resize_to => '
x50'
has_attachment :thumbnails => { :thumb => [50, 50], :geometry => 'x50' }
has_attachment :storage => :file_system, :path_prefix => 'public/files'
has_attachment :storage => :file_system, :path_prefix => 'public/files',
:content_type => :image, :resize_to => [50,50]
has_attachment :storage => :file_system, :path_prefix => 'public/files',
:thumbnails => { :thumb => [50, 50], :geometry => 'x50' }
has_attachment :storage => :s3
validates_as_attachment
This method prevents files outside of the valid range (:min_size to :max_size,
or the :size range) from being saved. It does not however, halt the upload of
such files. They will be uploaded into memory regardless of size before validat
ion.
Example:
validates_as_attachment
attachment_fu migrations
========================
Fields for attachment_fu metadata tables...
in general:
size, :integer # file size in bytes
content_type, :string # mime type, ex: application/mp3
filename, :string # sanitized filename
that reference images:
height, :integer # in pixels
width, :integer # in pixels
that reference images that will be thumbnailed:
parent_id, :integer # id of parent image (on the same table, a self-refe
rencing foreign-key).
# Only populated if the current object is a thumbnai
l.
thumbnail, :string # the 'type' of thumbnail this attachment record des
cribes.
# Only populated if the current object is a thumbnai
l.
# Usage:
# [ In Model 'Avatar' ]
# has_attachment :content_type => :image,
# :storage => :file_system,
# :max_size => 500.kilobytes,
# :resize_to => '320x200>',
# :thumbnails => { :small => '10x10
>',
# :thumb => '100x1
00>' }
# [ Elsewhere ]
# @user.avatar.thumbnails.first.thumbnail #=> 'small
'
that reference files stored in the database (:db_file):
db_file_id, :integer # id of the file in the database (foreign key)
Field for attachment_fu db_files table:
data, :binary # binary file data, for use in database file storage
attachment_fu views
===================
There are two main views tasks that will be directly affected by attachment_fu:
upload forms and displaying uploaded images.
There are two parts of the upload form that differ from typical usage.
1. Include ':multipart => true' in the html options of the form_for tag.
Example:
<% form_for(:attachment_metadata, :url => { :action => "create" }, :html =
> { :multipart => true }) do |form| %>
2. Use the file_field helper with :uploaded_data as the field name.
Example:
<%= form.file_field :uploaded_data %>
Displaying uploaded images is made easy by the public_filename method of the Act
iveRecord attachment objects using file system and s3 storage.
public_filename(thumbnail = nil)
Returns the public path to the file. If a thumbnail prefix is specified it wi
ll return the public file path to the corresponding thumbnail.
Examples:
attachment_obj.public_filename #=> /attachments/2/file.jpg
attachment_obj.public_filename(:thumb) #=> /attachments/2/file_thumb.jpg
attachment_obj.public_filename(:small) #=> /attachments/2/file_small.jpg
When serving files from database storage, doing more than simply downloading the
file is beyond the scope of this document.
attachment_fu controllers
=========================
There are two considerations to take into account when using attachment_fu in co
ntrollers.
The first is when the files have no publicly accessible path and need to be down
loaded through an action.
Example:
def readme
send_file '/path/to/readme.txt', :type => 'plain/text', :disposition => 'inl
ine'
end
See the possible values for send_file for reference.
The second is when saving the file when submitted from a form.
Example in view:
<%= form.file_field :attachable, :uploaded_data %>
Example in controller:
def create
@attachable_file = AttachmentMetadataModel.new(params[:attachable])
if @attachable_file.save
flash[:notice] = 'Attachment was successfully created.'
redirect_to attachable_url(@attachable_file)
else
render :action => :new
end
end
D:\radrails-0.7.2-win32\workspace\mm>
发表评论
-
rails3 终于出来了
2011-09-01 21:11 756... -
fckedit
2009-01-13 13:01 973http://www.blogjava.net/chengan ... -
login_engine
2009-01-13 11:10 1365http://svn.rails-engines.org/pl ... -
acts_as_attachme
2009-01-07 09:22 670http://techno-weenie.net/articl ... -
安装action_mailer_tls
2009-01-06 18:14 1279ruby script/plugin install http ... -
日志:get_tree 方法加强快照,十分注意",:method=>:get参数
2008-12-26 14:10 1216module DepartmentsHelper def ... -
日志:plugin discover终于能够plugin install 了啊,小东西还是挺有用的
2008-12-25 14:38 1075D:\radrails-0.7.2-win32\workspa ... -
ImageMagick + fleximage
2008-12-23 17:33 1298参考: http://rmagick.rubyforge.or ... -
rails2.2.2安装分页Log
2008-12-17 15:17 834D:\radrails-0.7.2-win32\workspa ... -
rake rails:freeze
2008-11-10 10:09 1854Ruby on Rails允许你”冻结”你的应用使用的Rail ... -
eclipse插件备案
2008-10-31 13:37 790http://propedit.sourceforge.jp/ ...
相关推荐
AT_Attachment_with_Packet_Interface_-_7_Volume_3
_storage_emulated_0_android_data_com.tencent.mm_MicroMsg_517174082dbc007f25c5bd836bdd4446_attachment_段润昌_648.wps
ATA接口的详细解读,working draft proposed American National Standard for Information Systems - ATA (ATAttachment) 78页
在MATLAB编程环境中,"H_attachment_comprose_matlab_"这个标题暗示了我们正在处理一个与图像处理或图形绘制相关的任务,特别是与生成特定形状的方位标志有关。方位标志通常用于图表中,以便清晰地指示出方向或者...
标题中的"attachment_1487958_16b_win64_2017-05-10"很可能是一个软件安装包或更新文件,尤其考虑到它与MATLAB 2016相关。这个文件名包含了几个关键信息:首先,“16b”可能表示这是MATLAB的一个版本号,可能是R2016...
CRC(Cyclic Redundancy Check,循环冗余校验)是一种广泛应用于数据传输和存储中的错误检测方法。在LTE(Long-Term Evolution)系统中,它对于确保下行物理链路的传输质量至关重要。本程序是专门针对LTE下行链路中...
Information Technology - AT Attachment with Packet Interface - 6 (ATA/ATAPI-6)ATA_ATAPI-6标准规范,驱动开发参考文档
#!/usr/bin/env python # coding: utf-8 # In[1]: import pandas as pd # Load the provided ...merged_data = pd.merge(attachment_2, attachment_1, on="单品编码", how="left") # Display the first few rows
very interesting matlab hev model
西门子840d数控系统说明。对方的更多更好
"attachment_finder_app" 是一个基于JavaScript开发的简单应用,主要用于帮助用户管理和标记带有附件的票证。这个应用程序的独特之处在于它允许用户自定义标签,这些标签可以方便地应用于各种票证,进而使得在报告、...
编程基础知识点-面向对象编程实践之矩形、圆、triangle 类设计 本资源摘要信息旨在提供编程基础知识点,通过面向对象编程实践,设计矩形、圆、triangle 类,以提高编程能力和问题解决能力。 矩形类 Rectangle ...
attachment_doc是一个SquirrelMail插件,允许用户使用其浏览器查看电子邮件中的文档附件。 该插件将文档转换为html格式。 目前支持MSWord(DOC)和可移植文档格式(PDF)!
"bugzilla_attachment_viewer" 是一个针对 Bugzilla 平台的 Chrome 浏览器扩展程序,它的主要功能是让用户能够在浏览器中直接内联查看图像附件,而无需下载这些文件到本地。这极大地提高了用户在处理 Bugzilla 中的...
在IT行业中,"Attachment_Project:附件项目"是一个可能与文件管理和Web应用相关的项目。这个项目的描述非常简洁,只提到了“附件项目”这个名字,没有提供具体的功能或目标。不过,结合给出的标签“HTML”,我们可以...
"backlog_attachment_alert" 是一个针对Backlog平台的Chrome扩展程序,它的主要功能是在用户创建问题或发表评论时提供附件提醒服务,确保用户不会遗漏任何重要的文件上传。这个扩展程序特别适用于那些依赖Backlog...
【标题解析】:“attachment_repo:我要分享的一些文件”这个标题表明这是一个分享的资源集合,主要可能包含各种与“attachment_repo”相关的文件。由于没有具体的上下文,我们可以理解为这是一个个人或者团队分享的...
Attachment 1_chazhi.xlsx
标题中的"566223_ATTACHMENT01_filamentwinding_filament_zip_"似乎是一个文件名,其中包含了关键词"filament winding",这通常是指一种制造复合材料管状或圆柱形结构的技术。该技术涉及将连续纤维(如碳纤维或玻璃...
"attachment_plugin" 是专门为 CKEditor 设计的一款附件插件,旨在增强编辑器的功能,允许用户方便地上传、管理和插入各种类型的文件到编辑内容中。此插件版本为 v4.0+,表明它是针对 CKEditor 4.x 系列的更新版本,...