MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / parseMultipart

Function parseMultipart

agent/middleware/operation.go:108–135  ·  view source on GitHub ↗
(formData []byte, contentType string)

Source from the content-addressed store, hash-verified

106}
107
108func parseMultipart(formData []byte, contentType string) (map[string]interface{}, error) {
109 d, params, err := mime.ParseMediaType(contentType)
110 if err != nil || d != "multipart/form-data" {
111 return nil, http.ErrNotMultipart
112 }
113 boundary, ok := params["boundary"]
114 if !ok {
115 return nil, http.ErrMissingBoundary
116 }
117 reader := multipart.NewReader(bytes.NewReader(formData), boundary)
118 ret := make(map[string]interface{})
119
120 f, err := reader.ReadForm(32 << 20)
121 if err != nil {
122 return nil, err
123 }
124 for k, v := range f.Value {
125 if len(v) > 0 {
126 ret[k] = v[0]
127 }
128 }
129 for k, v := range f.File {
130 if len(v) > 0 {
131 ret[k] = v[0].Filename
132 }
133 }
134 return ret, nil
135}
136
137func resolveOperationValues(pathItem string, values map[string]interface{}, beforeFunctions []functionInfo) (map[string]string, error) {
138 dbItem, err := newResolveDB(pathItem)

Callers 1

OperationResolveMetaFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected