We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e33887a commit 623a3d6Copy full SHA for 623a3d6
conv.go
@@ -3,11 +3,11 @@ package image
3
import (
4
"bytes"
5
"encoding/base64"
6
- "mime/multipart"
7
"image"
8
"image/jpeg"
9
- "io/ioutil"
10
"io"
+ "io/ioutil"
+ "mime/multipart"
11
"os"
12
)
13
@@ -80,7 +80,12 @@ func FileToBase64(srcFile string) ([]byte, error) {
80
81
// Bytes2file 直接转 multipart.File
82
func Bytes2file(b []byte) multipart.File {
83
- r := io.NewSectionReader(bytes.NewReader(b), 0, int64(len(b)))
+ return ReaderAt2file(bytes.NewReader(b), int64(len(b)))
84
+}
85
+
86
+// ReaderAt2file 直接转 multipart.File
87
+func ReaderAt2file(readerAt io.ReaderAt, size int64) multipart.File {
88
+ r := io.NewSectionReader(readerAt, 0, size)
89
return SectionReadCloser{r}
90
}
91
0 commit comments