diff --git a/README.md b/README.md
index 3b71354..53fdafb 100644
--- a/README.md
+++ b/README.md
@@ -272,15 +272,19 @@ type NotFoundHandle func(http.ResponseWriter, *http.Request)
websocket - golang.org/x/net/websocket
redis - github.com/garyburd/redigo/redis
-
+
+yaml - gopkg.in/yaml.v2
## 相关项目
-#### TokenServer
-项目简介:token服务,提供token一致性服务以及相关的全局ID生成服务等
-
#### LongWeb
项目简介:http长连接网关服务,提供Websocket及长轮询服务
+#### yulibaozi.com
+项目简介:基于dotweb与mapper的一款go的博客程序
+
+#### TokenServer
+项目简介:token服务,提供token一致性服务以及相关的全局ID生成服务等
+
## 贡献名单
目前已经有几位朋友在为框架一起做努力,我们将在合适的时间向大家展现,谢谢他们的支持!
diff --git a/consts.go b/consts.go
index a582bc2..90921c3 100644
--- a/consts.go
+++ b/consts.go
@@ -1,5 +1,10 @@
package dotweb
+//dotweb const
+const (
+ Version = "1.4.5.1"
+)
+
//Log define
const (
LogTarget_Default = "dotweb_default"
diff --git a/uploadfile.go b/uploadfile.go
index 48d9cbb..c18b16a 100644
--- a/uploadfile.go
+++ b/uploadfile.go
@@ -3,6 +3,7 @@ package dotweb
import (
"bytes"
"errors"
+ "io"
"mime/multipart"
"os"
"path/filepath"
@@ -14,7 +15,6 @@ type UploadFile struct {
fileExt string //file extensions
fileName string
fileSize int64
- content []byte
}
func NewUploadFile(file multipart.File, header *multipart.FileHeader) *UploadFile {
@@ -23,7 +23,6 @@ func NewUploadFile(file multipart.File, header *multipart.FileHeader) *UploadFil
Header: header,
fileName: header.Filename,
fileExt: filepath.Ext(header.Filename), //update for issue #99
- content: parseFileToBytes(file),
}
}
@@ -47,8 +46,10 @@ func (f *UploadFile) Size() int64 {
return f.fileSize
}
-//save file in server-local with filename
-func (f *UploadFile) SaveFile(fileName string) (size int, err error) {
+// SaveFile save file in server-local with filename
+// special:
+// if you SaveFile, it's will cause empty data when use ReadBytes
+func (f *UploadFile) SaveFile(fileName string) (size int64, err error) {
size = 0
if fileName == "" {
return size, errors.New("filename not allow empty")
@@ -59,9 +60,7 @@ func (f *UploadFile) SaveFile(fileName string) (size int, err error) {
return size, err
}
defer fileWriter.Close()
- f.File.Read(f.content)
- //size, err = io.Copy(fileWriter, f.File)
- size, err = fileWriter.Write(f.content)
+ size, err = io.Copy(fileWriter, f.File)
return size, err
}
@@ -71,12 +70,10 @@ func (f *UploadFile) GetFileExt() string {
}
// Bytes returns a slice of byte hoding the UploadFile.File
-func (f *UploadFile) Bytes() []byte {
- return f.content
-}
-
-func parseFileToBytes(file multipart.File) []byte {
+// special:
+// if you read bytes, it's will cause empty data in UploadFile.File, so you use SaveFile will no any data to save
+func (f *UploadFile) ReadBytes() []byte {
buf := new(bytes.Buffer)
- buf.ReadFrom(file)
+ buf.ReadFrom(f.File)
return buf.Bytes()
}
diff --git a/version.MD b/version.MD
index 163290a..5c0477e 100644
--- a/version.MD
+++ b/version.MD
@@ -1,5 +1,11 @@
## dotweb版本记录:
+#### Version 1.4.6
+* BUG Fixed: UploadFile废弃Bytes接口,新增ReadBytes接口,用于返回上传文件本身
+* 需要特别注意,由于io.read具有一次性特性,UploadFile.SaveFile与UploadFile.ReadBytes只能使用其中一个,另外一个将无法正常获取数据
+* 增加dotweb.Version,用于输出框架版本号
+* 2018-01-21 09:00
+
#### Version 1.4.5
* 新增yaml格式配置文件支持,具体参考 example/config/dotweb.yaml
* config新增UnmarshalYaml\MarshalYaml\MarshalYamlString,提供针对Yaml的常规处理