leangem 2.1.4 → 2.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fileupload.rb +11 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bcf4bf14cf2fd42ef26a9fb305c000045eb5854
|
4
|
+
data.tar.gz: 25ace4ef9f12b8c680d88574907e9614b4505943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80053532beb034406eea4c95e5e0e56536f6374423da5cb445d61258242c189b973d68c6c196b2edfaf634a8dbb55b1652769002e0cf9cb2f14d8883bc6fe59f
|
7
|
+
data.tar.gz: 82d3916200e5f576dbbfde927663775bf7f0a75d1642953654f8cc9c056189a2bfb5366bd13ef625b72165a7798c3a3c6546d7d9c429236cbb57ef540e784143
|
data/lib/fileupload.rb
CHANGED
@@ -8,15 +8,17 @@ class Fileupload
|
|
8
8
|
sname = Fileupload.getname(file, filepath)
|
9
9
|
begin
|
10
10
|
unless Dir::exist?(filepath)
|
11
|
-
|
12
|
-
|
11
|
+
unless system("mkdir #{filepath}")
|
12
|
+
return {state: false, result: "目录创建失败,请于管理员联系"}
|
13
|
+
end
|
14
|
+
end
|
13
15
|
File.open(filepath+sname, "wb") do |f|
|
14
16
|
f.write(file.read)
|
15
17
|
end
|
18
|
+
return {state: true, result: sname}
|
16
19
|
rescue
|
17
20
|
return {state: false, result: "写入文件失败:#{$!}"}
|
18
21
|
end
|
19
|
-
return {state: true, result: sname}
|
20
22
|
else
|
21
23
|
return {state: false, result: result[:message]}
|
22
24
|
end
|
@@ -73,16 +75,18 @@ class Fileupload
|
|
73
75
|
sname = Fileupload.getname(imgfile, filepath)
|
74
76
|
begin
|
75
77
|
unless Dir::exist?(filepath)
|
76
|
-
|
77
|
-
|
78
|
+
unless system("mkdir #{filepath}")
|
79
|
+
return {state: false, result: "目录创建失败,请于管理员联系"}
|
80
|
+
end
|
81
|
+
end
|
78
82
|
File.open(filepath+sname, "wb") do |f|
|
79
83
|
f.write(imgfile.read)
|
80
84
|
end
|
85
|
+
Fileupload.resize(filepath + sname, w, h)
|
86
|
+
return {state: true, result: sname}
|
81
87
|
rescue
|
82
88
|
return {state: false, result: "写入图片失败:#{$!}"}
|
83
89
|
end
|
84
|
-
Fileupload.resize(filepath + sname, w, h)
|
85
|
-
return {state: true, result: sname}
|
86
90
|
else
|
87
91
|
return {state: false, result: result[:message]}
|
88
92
|
end
|