package oss_utils import ( "context" "property-garden/parser" "property-garden/pb" pb_v1 "property-garden/pb/v1" "regexp" "strings" ) func IsFix(src string) bool { if strings.Contains(src, parser.Conf.Oss.RentObj) || strings.Contains(src, parser.Conf.Oss.EventObj) || strings.Contains(src, parser.Conf.Oss.VoteObj) { return true } return false } func GetObjFromText(text string) []string { rule := "img src=\".*?\"" reg, _ := regexp.Compile(rule) result := reg.FindAllStringSubmatch(text, -1) if len(result) == 0 { return []string{} } ret := []string{} key := "img src=\"" keyLength := len(key) for _, array := range result { if len(array) == 0 { continue } str := array[0] if len(str) < keyLength+1 { continue } str = str[keyLength:] str = str[:len(str)-1] ret = append(ret, str) } return ret } func OssObjAdd(inList []string, outList []string) error { mreq := pb_v1.OssObjAddRequest{InList: inList, OutList: outList} _, err := pb.Common.OssObjAdd(context.Background(), &mreq) return err }