@@ -143,6 +143,12 @@ const (
143
143
"是否合并小文件": "默认不合并,合并可以解决inode不够用的情况(当前对于小于1M文件)进行合并",
144
144
"enable_merge_small_file": false,
145
145
"允许后缀名": "允许可以上传的文件后缀名,如jpg,jpeg,png等。留空允许所有。",
146
+ "图片是否缩放": "默认是",
147
+ "enable_image_resize": true,
148
+ "图片最大宽度": "默认值2000",
149
+ "image_max_width": 2000,
150
+ "图片最大高度": "默认值1000",
151
+ "image_max_height": 1000,
146
152
"extensions": [],
147
153
"重试同步失败文件的时间": "单位秒",
148
154
"refresh_interval": 1800,
@@ -152,7 +158,7 @@ const (
152
158
"enable_web_upload": true,
153
159
"是否支持非日期路径": "默认支持非日期路径,也即支持自定义路径,需要上传文件时指定path",
154
160
"enable_custom_path": true,
155
- "下载域名": "用于外网下载文件的域名,不包含http:// ",
161
+ "下载域名": "用于外网下载文件的域名",
156
162
"download_domain": "",
157
163
"场景列表": "当设定后,用户指的场景必项在列表中,默认不做限制(注意:如果想开启场景认功能,格式如下:'场景名:googleauth_secret' 如 default:N7IET373HB2C5M6D ",
158
164
"scenes": [],
@@ -178,7 +184,7 @@ const (
178
184
"auto_repair": true,
179
185
"文件去重算法md5可能存在冲突,默认md5": "sha1|md5",
180
186
"file_sum_arithmetic": "md5",
181
- "管理ip列表": "用于管理集的ip白名单,",
187
+ "管理ip列表": "用于管理集的ip白名单,如果放开所有内网则可以用 0.0.0.0 ,注意为了安全,不对外网开放 ",
182
188
"admin_ips": ["127.0.0.1"],
183
189
"是否启用迁移": "默认不启用",
184
190
"enable_migrate": false,
@@ -322,6 +328,8 @@ type GloablConfig struct {
322
328
RetryCount int `json:"retry_count"`
323
329
SyncDelay int64 `json:"sync_delay"`
324
330
WatchChanSize int `json:"watch_chan_size"`
331
+ ImageMaxWidth int `json:"image_max_width"`
332
+ ImageMaxHeight int `json:"image_max_height"`
325
333
}
326
334
type FileInfoResult struct {
327
335
Name string `json:"name"`
@@ -1175,12 +1183,18 @@ func (this *Server) DownloadSmallFileByURI(w http.ResponseWriter, r *http.Reques
1175
1183
if err != nil {
1176
1184
log .Error (err )
1177
1185
}
1186
+ if imgWidth > Config ().ImageMaxWidth {
1187
+ imgWidth = Config ().ImageMaxWidth
1188
+ }
1178
1189
}
1179
1190
if height != "" {
1180
1191
imgHeight , err = strconv .Atoi (height )
1181
1192
if err != nil {
1182
1193
log .Error (err )
1183
1194
}
1195
+ if imgHeight > Config ().ImageMaxHeight {
1196
+ imgHeight = Config ().ImageMaxHeight
1197
+ }
1184
1198
}
1185
1199
data , notFound , err = this .GetSmallFileByURI (w , r )
1186
1200
_ = notFound
@@ -1221,12 +1235,18 @@ func (this *Server) DownloadNormalFileByURI(w http.ResponseWriter, r *http.Reque
1221
1235
if err != nil {
1222
1236
log .Error (err )
1223
1237
}
1238
+ if imgWidth > Config ().ImageMaxWidth {
1239
+ imgWidth = Config ().ImageMaxWidth
1240
+ }
1224
1241
}
1225
1242
if height != "" {
1226
1243
imgHeight , err = strconv .Atoi (height )
1227
1244
if err != nil {
1228
1245
log .Error (err )
1229
1246
}
1247
+ if imgHeight > Config ().ImageMaxHeight {
1248
+ imgHeight = Config ().ImageMaxHeight
1249
+ }
1230
1250
}
1231
1251
if isDownload {
1232
1252
this .SetDownloadHeader (w , r )
@@ -1358,6 +1378,7 @@ func (this *Server) ResizeImageByBytes(w http.ResponseWriter, data []byte, width
1358
1378
log .Error (err )
1359
1379
return
1360
1380
}
1381
+ fmt .Println (width , height )
1361
1382
img = resize .Resize (width , height , img , resize .Lanczos3 )
1362
1383
if imgType == "jpg" || imgType == "jpeg" {
1363
1384
jpeg .Encode (w , img , nil )
@@ -4317,6 +4338,12 @@ func (this *Server) initComponent(isReload bool) {
4317
4338
if Config ().WatchChanSize == 0 {
4318
4339
Config ().WatchChanSize = 100000
4319
4340
}
4341
+ if Config ().ImageMaxHeight == 0 {
4342
+ Config ().ImageMaxHeight = 2000
4343
+ }
4344
+ if Config ().ImageMaxWidth == 0 {
4345
+ Config ().ImageMaxWidth = 2000
4346
+ }
4320
4347
}
4321
4348
4322
4349
type HttpHandler struct {
0 commit comments