MCPcopy
hub / github.com/hwholiday/learning_tools / findFile

Function findFile

minio/old/main.go:79–102  ·  view source on GitHub ↗

查找文件

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

77
78//查找文件
79func findFile(w http.ResponseWriter, r *http.Request) {
80 if r.Method != "GET" {
81 w.Write([]byte("请使用GET方法"))
82 return
83 }
84 r.ParseForm()
85 id := r.Form.Get("id")
86 if id == "" {
87 w.Write([]byte("请传入资源ID"))
88 return
89 }
90 v, ok := FileMap.Load(id)
91 if !ok {
92 w.Write([]byte("没有找到该资源"))
93 return
94 }
95 info, err := MinioClient.PresignedGetObject(bucket, fmt.Sprint(v), FILE_TIMEOUT, nil)
96 if err != nil {
97 w.Write([]byte(err.Error()))
98 return
99 }
100 w.Write([]byte(info.String()))
101 return
102}
103
104//删除文件
105func removeFile(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 5

WriteMethod · 0.80
GetMethod · 0.65
LoadMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected