Skip to content

Commit

Permalink
添加自述文件
Browse files Browse the repository at this point in the history
  • Loading branch information
onenewcode committed Apr 1, 2024
1 parent 0dcb5cd commit b2a1b9f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 工作流程
## 后端工作流程
### 通用功能
#### 上传图片
目前图片会上传到自建的Minio服务器中,具体的工作流程如下。

# 第一章 构建项目框架
## 初始化项目结构
首先介绍开始时我们的项目的总体结构,结构和注释如下,大家可以跟着创建相同的结构,也可以按照自己的思维进行一定的更改。
Expand Down
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ require (
require (
golang.org/x/crypto v0.19.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
)

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
Expand Down
1 change: 1 addition & 0 deletions internal/router/admin/common_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

func getFile(from *multipart.Form) *multipart.FileHeader {
// 获取文件对应的文件头
fileH := from.File["file"][0]
return fileH
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/obs/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ func (*MyMinio) UploadImg(fh *multipart.FileHeader) *string {
id := uuid.New()
str.WriteString(id.String())
str.WriteString(path.Ext(fh.Filename))
// 构建文件在Minio的存储路径
filepath := str.String()
// 获取文件的读取流
file_body, _ := fh.Open()
_, err := minioClient.PutObject(bucketName, filepath, file_body, fh.Size, minio.PutObjectOptions{
ContentType: fh.Header.Get("Content-Type"),
})
// 拼接返回路径
filepath = "http://" + path.Join(endpoint, bucketName, filepath)
if err != nil {
log.Fatalln(err)
Expand Down

0 comments on commit b2a1b9f

Please sign in to comment.