MCPcopy Create free account
hub / github.com/aurora-develop/aurora / normalizeImageEditImages

Function normalizeImageEditImages

initialize/handlers.go:932–967  ·  view source on GitHub ↗
(rawImages []interface{})

Source from the content-addressed store, hash-verified

930}
931
932func normalizeImageEditImages(rawImages []interface{}) []editImageInput {
933 out := make([]editImageInput, 0, len(rawImages))
934 for _, raw := range rawImages {
935 switch v := raw.(type) {
936 case *multipart.FileHeader:
937 if v == nil {
938 continue
939 }
940 f, err := v.Open()
941 if err != nil {
942 continue
943 }
944 data, err := io.ReadAll(f)
945 f.Close()
946 if err != nil || len(data) == 0 {
947 continue
948 }
949 ct := v.Header.Get("Content-Type")
950 if ct == "" {
951 ct = "image/png"
952 }
953 name := v.Filename
954 if name == "" {
955 name = "image.png"
956 }
957 out = append(out, editImageInput{Data: data, Filename: name, ContentType: ct})
958 case editImageInput:
959 if len(v.Data) > 0 {
960 out = append(out, v)
961 }
962 default:
963 // JSON 形态的 image 引用由 collectImageEditSourcesFromValue 处理,这里跳过
964 }
965 }
966 return out
967}
968
969func imageEditReadJSONImage(data []byte, filename, contentType string) (editImageInput, error) {
970 if len(data) == 0 {

Callers 1

runImageEditFlowMethod · 0.85

Calls 1

GetMethod · 0.80

Tested by

no test coverage detected