Skip to content

Commit 623a3d6

Browse files
committed
update
1 parent e33887a commit 623a3d6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

conv.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package image
33
import (
44
"bytes"
55
"encoding/base64"
6-
"mime/multipart"
76
"image"
87
"image/jpeg"
9-
"io/ioutil"
108
"io"
9+
"io/ioutil"
10+
"mime/multipart"
1111
"os"
1212
)
1313

@@ -80,7 +80,12 @@ func FileToBase64(srcFile string) ([]byte, error) {
8080

8181
// Bytes2file 直接转 multipart.File
8282
func Bytes2file(b []byte) multipart.File {
83-
r := io.NewSectionReader(bytes.NewReader(b), 0, int64(len(b)))
83+
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)
8489
return SectionReadCloser{r}
8590
}
8691

0 commit comments

Comments
 (0)