Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
bdfeebda
Commit
bdfeebda
authored
Jan 27, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some style change
parent
5ffcc855
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
lib/paperclip/attachment.rb
+14
-14
lib/paperclip/upfile.rb
+4
-2
No files found.
lib/paperclip/attachment.rb
View file @
bdfeebda
...
@@ -11,29 +11,29 @@ module Paperclip
...
@@ -11,29 +11,29 @@ module Paperclip
def
self
.
default_options
def
self
.
default_options
@default_options
||=
{
@default_options
||=
{
:url
=>
"/system/:attachment/:id/:style/:filename"
,
:convert_options
=>
{},
:path
=>
":rails_root/public:url"
,
:default_style
=>
:original
,
:styles
=>
{},
:default_url
=>
"/:attachment/:style/missing.png"
,
:hash_data
=>
":class/:attachment/:id/:style/:updated_at"
,
:hash_digest
=>
"SHA1"
,
:interpolator
=>
Paperclip
::
Interpolations
,
:only_process
=>
[],
:only_process
=>
[],
:path
=>
":rails_root/public:url"
,
:preserve_files
=>
false
,
:processors
=>
[
:thumbnail
],
:processors
=>
[
:thumbnail
],
:convert_options
=>
{},
:source_file_options
=>
{},
:source_file_options
=>
{},
:default_url
=>
"/:attachment/:style/missing.png"
,
:default_style
=>
:original
,
:storage
=>
:filesystem
,
:storage
=>
:filesystem
,
:styles
=>
{},
:url
=>
"/system/:attachment/:id/:style/:filename"
,
:url_generator
=>
Paperclip
::
UrlGenerator
:use_default_time_zone
=>
true
,
:use_timestamp
=>
true
,
:use_timestamp
=>
true
,
:whiny
=>
Paperclip
.
options
[
:whiny
]
||
Paperclip
.
options
[
:whiny_thumbnails
],
:whiny
=>
Paperclip
.
options
[
:whiny
]
||
Paperclip
.
options
[
:whiny_thumbnails
],
:use_default_time_zone
=>
true
,
:hash_digest
=>
"SHA1"
,
:hash_data
=>
":class/:attachment/:id/:style/:updated_at"
,
:preserve_files
=>
false
,
:interpolator
=>
Paperclip
::
Interpolations
,
:url_generator
=>
Paperclip
::
UrlGenerator
}
}
end
end
attr_reader
:name
,
:instance
,
:default_style
,
:convert_options
,
:queued_for_write
,
:whiny
,
:options
,
:interpolator
attr_reader
:name
,
:instance
,
:default_style
,
:convert_options
,
:queued_for_write
,
:whiny
,
attr_reader
:source_file_options
,
:whiny
:options
,
:interpolator
,
:source_file_options
,
:whiny
attr_accessor
:post_processing
attr_accessor
:post_processing
# Creates an Attachment object. +name+ is the name of the attachment,
# Creates an Attachment object. +name+ is the name of the attachment,
...
...
lib/paperclip/upfile.rb
View file @
bdfeebda
...
@@ -5,7 +5,6 @@ module Paperclip
...
@@ -5,7 +5,6 @@ module Paperclip
# to the +File+ class. Useful for testing.
# to the +File+ class. Useful for testing.
# user.avatar = File.new("test/test_avatar.jpg")
# user.avatar = File.new("test/test_avatar.jpg")
module
Upfile
module
Upfile
# Infer the MIME-type of the file from the extension.
# Infer the MIME-type of the file from the extension.
def
content_type
def
content_type
types
=
MIME
::
Types
.
type_for
(
self
.
original_filename
)
types
=
MIME
::
Types
.
type_for
(
self
.
original_filename
)
...
@@ -23,7 +22,7 @@ module Paperclip
...
@@ -23,7 +22,7 @@ module Paperclip
end
end
def
type_from_file_command
def
type_from_file_command
# On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
# On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
type
=
(
self
.
original_filename
.
match
(
/\.(\w+)$/
)[
1
]
rescue
"octet-stream"
).
downcase
type
=
(
self
.
original_filename
.
match
(
/\.(\w+)$/
)[
1
]
rescue
"octet-stream"
).
downcase
mime_type
=
(
Paperclip
.
run
(
"file"
,
"-b --mime :file"
,
:file
=>
self
.
path
).
split
(
/[:;]\s+/
)[
0
]
rescue
"application/x-
#{
type
}
"
)
mime_type
=
(
Paperclip
.
run
(
"file"
,
"-b --mime :file"
,
:file
=>
self
.
path
).
split
(
/[:;]\s+/
)[
0
]
rescue
"application/x-
#{
type
}
"
)
mime_type
=
"application/x-
#{
type
}
"
if
mime_type
.
match
(
/\(.*?\)/
)
mime_type
=
"application/x-
#{
type
}
"
if
mime_type
.
match
(
/\(.*?\)/
)
...
@@ -45,12 +44,15 @@ end
...
@@ -45,12 +44,15 @@ end
if
defined?
StringIO
if
defined?
StringIO
class
StringIO
class
StringIO
attr_accessor
:original_filename
,
:content_type
,
:fingerprint
attr_accessor
:original_filename
,
:content_type
,
:fingerprint
def
original_filename
def
original_filename
@original_filename
||=
"stringio.txt"
@original_filename
||=
"stringio.txt"
end
end
def
content_type
def
content_type
@content_type
||=
"text/plain"
@content_type
||=
"text/plain"
end
end
def
fingerprint
def
fingerprint
@fingerprint
||=
Digest
::
MD5
.
hexdigest
(
self
.
string
)
@fingerprint
||=
Digest
::
MD5
.
hexdigest
(
self
.
string
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment