|
|
|
@@ -7,11 +7,12 @@ import ( |
|
|
|
"mime" |
|
|
|
"mime/multipart" |
|
|
|
"net/http" |
|
|
|
"net/textproto" |
|
|
|
ul "net/url" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"gitlink.org.cn/cloudream/common/pkgs/iterator" |
|
|
|
"gitlink.org.cn/cloudream/common/utils/math" |
|
|
|
"gitlink.org.cn/cloudream/common/utils/math2" |
|
|
|
"gitlink.org.cn/cloudream/common/utils/serder" |
|
|
|
) |
|
|
|
|
|
|
|
@@ -129,13 +130,14 @@ func ParseJSONResponse[TBody any](resp *http.Response) (TBody, error) { |
|
|
|
} |
|
|
|
strCont := string(cont) |
|
|
|
|
|
|
|
return ret, fmt.Errorf("unknow response content type: %s, status: %d, body(prefix): %s", contType, resp.StatusCode, strCont[:math.Min(len(strCont), 200)]) |
|
|
|
return ret, fmt.Errorf("unknow response content type: %s, status: %d, body(prefix): %s", contType, resp.StatusCode, strCont[:math2.Min(len(strCont), 200)]) |
|
|
|
} |
|
|
|
|
|
|
|
type MultiPartFile struct { |
|
|
|
FieldName string |
|
|
|
FileName string |
|
|
|
File io.ReadCloser |
|
|
|
Header textproto.MIMEHeader |
|
|
|
} |
|
|
|
|
|
|
|
type multiPartFileIterator struct { |
|
|
|
@@ -157,6 +159,7 @@ func (m *multiPartFileIterator) MoveNext() (*MultiPartFile, error) { |
|
|
|
FieldName: f.FormName(), |
|
|
|
FileName: fileName, |
|
|
|
File: f, |
|
|
|
Header: f.Header, |
|
|
|
}, nil |
|
|
|
} |
|
|
|
|
|
|
|
@@ -179,6 +182,7 @@ func (m *multiPartFileIterator) MoveNext() (*MultiPartFile, error) { |
|
|
|
FieldName: part.FormName(), |
|
|
|
FileName: fileName, |
|
|
|
File: part, |
|
|
|
Header: part.Header, |
|
|
|
}, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|