Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
711dd229
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
711dd229
编写于
8月 30, 2017
作者:
R
Ryuta Kamizono
提交者:
GitHub
8月 30, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #30456 from yhirano55/update_activestorage_docs
Update Active Storage docs [ci skip]
上级
9a66a221
e38900b8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
9 deletion
+17
-9
activestorage/app/models/active_storage/blob.rb
activestorage/app/models/active_storage/blob.rb
+2
-2
activestorage/app/models/active_storage/filename.rb
activestorage/app/models/active_storage/filename.rb
+13
-5
activestorage/lib/active_storage/attached/one.rb
activestorage/lib/active_storage/attached/one.rb
+1
-1
activestorage/lib/active_storage/service.rb
activestorage/lib/active_storage/service.rb
+1
-1
未找到文件。
activestorage/app/models/active_storage/blob.rb
浏览文件 @
711dd229
...
...
@@ -3,8 +3,8 @@
# A blob is a record that contains the metadata about a file and a key for where that file resides on the service.
# Blobs can be created in two ways:
#
# 1
)
Subsequent to the file being uploaded server-side to the service via <tt>create_after_upload!</tt>.
# 2
)
Ahead of the file being directly uploaded client-side to the service via <tt>create_before_direct_upload!</tt>.
# 1
.
Subsequent to the file being uploaded server-side to the service via <tt>create_after_upload!</tt>.
# 2
.
Ahead of the file being directly uploaded client-side to the service via <tt>create_before_direct_upload!</tt>.
#
# The first option doesn't require any client-side JavaScript integration, and can be used by any other back-end
# service that deals with files. The second option is faster, since you're not using your own server as a staging
...
...
activestorage/app/models/active_storage/filename.rb
浏览文件 @
711dd229
...
...
@@ -9,25 +9,33 @@ def initialize(filename)
@filename
=
filename
end
# Filename.new("racecar.jpg").base # => "racecar"
# Returns the basename of the filename.
#
# ActiveStorage::Filename.new("racecar.jpg").base # => "racecar"
def
base
File
.
basename
@filename
,
extension_with_delimiter
end
# Filename.new("racecar.jpg").extension_with_delimiter # => ".jpg"
# Returns the extension with delimiter of the filename.
#
# ActiveStorage::Filename.new("racecar.jpg").extension_with_delimiter # => ".jpg"
def
extension_with_delimiter
File
.
extname
@filename
end
# Filename.new("racecar.jpg").extension_without_delimiter # => "jpg"
# Returns the extension without delimiter of the filename.
#
# ActiveStorage::Filename.new("racecar.jpg").extension_without_delimiter # => "jpg"
def
extension_without_delimiter
extension_with_delimiter
.
from
(
1
).
to_s
end
alias_method
:extension
,
:extension_without_delimiter
# Filename.new("foo:bar.jpg").sanitized # => "foo-bar.jpg"
# Filename.new("foo/bar.jpg").sanitized # => "foo-bar.jpg"
# Returns the sanitized filename.
#
# ActiveStorage::Filename.new("foo:bar.jpg").sanitized # => "foo-bar.jpg"
# ActiveStorage::Filename.new("foo/bar.jpg").sanitized # => "foo-bar.jpg"
#
# ...and any other character unsafe for URLs or storage is converted or stripped.
def
sanitized
...
...
activestorage/lib/active_storage/attached/one.rb
浏览文件 @
711dd229
...
...
@@ -25,7 +25,7 @@ def attach(attachable)
ActiveStorage
::
Attachment
.
create!
(
record:
record
,
name:
name
,
blob:
create_blob_from
(
attachable
))
end
# Returns
true
if an attachment has been made.
# Returns
+true+
if an attachment has been made.
#
# class User < ActiveRecord::Base
# has_one_attached :avatar
...
...
activestorage/lib/active_storage/service.rb
浏览文件 @
711dd229
...
...
@@ -77,7 +77,7 @@ def delete(key)
raise
NotImplementedError
end
# Return
true
if a file exists at the +key+.
# Return
+true+
if a file exists at the +key+.
def
exist?
(
key
)
raise
NotImplementedError
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录