1、修改存储路径
This commit is contained in:
		
							parent
							
								
									a7482bb81a
								
							
						
					
					
						commit
						1dac293b9b
					
				|  | @ -5,6 +5,7 @@ type FileManager struct { | ||||||
| 	FileName  string `xorm:"VARCHAR(200)" json:"fileName"`               //文件名
 | 	FileName  string `xorm:"VARCHAR(200)" json:"fileName"`               //文件名
 | ||||||
| 	AccessUrl string `xorm:"VARCHAR(400)" json:"url"`                    //访问路径
 | 	AccessUrl string `xorm:"VARCHAR(400)" json:"url"`                    //访问路径
 | ||||||
| 	Scene     string `xorm:"VARCHAR(40)" json:"scene"`                   //应用场景,0 : 其他, 1: 道路; 2: 桥梁; 3:隧道; 4: 边坡
 | 	Scene     string `xorm:"VARCHAR(40)" json:"scene"`                   //应用场景,0 : 其他, 1: 道路; 2: 桥梁; 3:隧道; 4: 边坡
 | ||||||
|  | 	DataType  int    `xorm:"TINYINT index default 0" json:"dataType"`    //数据类型,1:数据集;2:病害库;3:应用;0:其他
 | ||||||
| 	DatasetId int64  `xorm:"INT(11) index default 0" json:"datasetId"`   //数据集
 | 	DatasetId int64  `xorm:"INT(11) index default 0" json:"datasetId"`   //数据集
 | ||||||
| 	FileSize  int64  `xorm:"BIGINT" json:"fileSize"`                     //文件大小
 | 	FileSize  int64  `xorm:"BIGINT" json:"fileSize"`                     //文件大小
 | ||||||
| 	FileMd5   string `xorm:"VARCHAR(64)" json:"fileMd5"`                 //文件MD5
 | 	FileMd5   string `xorm:"VARCHAR(64)" json:"fileMd5"`                 //文件MD5
 | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"github.com/minio/minio-go/v7" | 	"github.com/minio/minio-go/v7" | ||||||
| 	"os" | 	"os" | ||||||
|  | 	"path" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"git.hpds.cc/pavement/hpds_node" | 	"git.hpds.cc/pavement/hpds_node" | ||||||
|  | @ -120,12 +121,12 @@ func handler(data []byte) (byte, []byte) { | ||||||
| 						Error("错误信息", zap.Error(err)) | 						Error("错误信息", zap.Error(err)) | ||||||
| 				} | 				} | ||||||
| 				fileReader := bytes.NewReader(fileContent) | 				fileReader := bytes.NewReader(fileContent) | ||||||
| 				info, err := global.MinioClient.PutObject(context.Background(), global.Cfg.Minio.Bucket, fmt.Sprintf("%s%s", model.GetDatasetScene(dt.CategoryId), payload["filePath"].(string)), fileReader, int64(payload["fileSize"].(float64)), minio.PutObjectOptions{ContentType: "application/octet-stream"}) | 				info, err := global.MinioClient.PutObject(context.Background(), global.Cfg.Minio.Bucket, path.Join(model.GetDatasetScene(dt.CategoryId), dt.StoreName, payload["filePath"].(string)), fileReader, int64(payload["fileSize"].(float64)), minio.PutObjectOptions{ContentType: "application/octet-stream"}) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					global.Logger.With(zap.String("文件名称", payload["filePath"].(string))).With(zap.Int64("文件大小", int64(payload["fileSize"].(float64)))). | 					global.Logger.With(zap.String("文件名称", payload["filePath"].(string))).With(zap.Int64("文件大小", int64(payload["fileSize"].(float64)))). | ||||||
| 						Error("错误信息", zap.Error(err)) | 						Error("错误信息", zap.Error(err)) | ||||||
| 				} | 				} | ||||||
| 				accessUrl := fmt.Sprintf("%s://%s/%s/%s%s", global.Cfg.Minio.Protocol, global.Cfg.Minio.Endpoint, global.Cfg.Minio.Bucket, model.GetDatasetScene(dt.CategoryId), payload["filePath"].(string)) | 				accessUrl := fmt.Sprintf("%s://%s", global.Cfg.Minio.Protocol, path.Join(global.Cfg.Minio.Endpoint, global.Cfg.Minio.Bucket, info.Key)) | ||||||
| 
 | 
 | ||||||
| 				global.Logger.With(zap.String("文件名称", payload["filePath"].(string))).With(zap.String("访问路径", accessUrl)). | 				global.Logger.With(zap.String("文件名称", payload["filePath"].(string))).With(zap.String("访问路径", accessUrl)). | ||||||
| 					With(zap.Any("返回数据", info)).Info("文件上传到minio") | 					With(zap.Any("返回数据", info)).Info("文件上传到minio") | ||||||
|  | @ -133,6 +134,7 @@ func handler(data []byte) (byte, []byte) { | ||||||
| 				fm.FileName = payload["fileName"].(string) | 				fm.FileName = payload["fileName"].(string) | ||||||
| 				fm.AccessUrl = accessUrl | 				fm.AccessUrl = accessUrl | ||||||
| 				fm.Scene = fmt.Sprintf("%d", dt.CategoryId) | 				fm.Scene = fmt.Sprintf("%d", dt.CategoryId) | ||||||
|  | 				fm.DataType = int(payload["dataType"].(float64)) | ||||||
| 				fm.DatasetId = dt.DatasetId | 				fm.DatasetId = dt.DatasetId | ||||||
| 				fm.FileSize = int64(payload["fileSize"].(float64)) | 				fm.FileSize = int64(payload["fileSize"].(float64)) | ||||||
| 				fm.FileMd5 = payload["fileMd5"].(string) | 				fm.FileMd5 = payload["fileMd5"].(string) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue