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
a7f01bec
Commit
a7f01bec
authored
Jul 09, 2008
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed auto-content-typing in Upfile to be a little more intelligent.
parent
201c84ba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
lib/paperclip/upfile.rb
+7
-5
No files found.
lib/paperclip/upfile.rb
View file @
a7f01bec
...
...
@@ -6,12 +6,13 @@ module Paperclip
# Infer the MIME-type of the file from the extension.
def
content_type
type
=
self
.
path
.
match
(
/\.(\w+)$/
)[
1
]
rescue
"octet-stream"
type
=
(
self
.
path
.
match
(
/\.(\w+)$/
)[
1
]
rescue
"octet-stream"
).
downcase
case
type
when
"jpg"
then
"image/jpeg"
when
"png"
,
"gif"
then
"image/
#{
type
}
"
when
"txt"
then
"text/plain"
when
"csv"
,
"xml"
,
"html"
,
"htm"
,
"css"
,
"js"
then
"text/
#{
type
}
"
when
%r"jpe?g"
then
"image/jpeg"
when
%r"png"
,
"gif"
,
"bmp"
,
"tiff"
then
"image/
#{
type
}
"
when
"txt"
then
"text/plain"
when
%r"html?"
then
"text/html"
when
"csv"
,
"xml"
,
"css"
,
"js"
then
"text/
#{
type
}
"
else
"application/x-
#{
type
}
"
end
end
...
...
@@ -32,3 +33,4 @@ end
class
File
#:nodoc:
include
Paperclip
::
Upfile
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