diff options
| author | Chris Lu <chris.lu@gmail.com> | 2015-12-14 21:42:38 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2015-12-14 21:42:38 -0800 |
| commit | df5e54e02af60f6a1537cd5853def4dad42932bc (patch) | |
| tree | 1037c5cff81bfda50ca42a3249ebaeeb3774501e /go/storage/needle.go | |
| parent | 020dd480ed8dab0eeb3b6b25b2558084a51b26f2 (diff) | |
| parent | 031d26527f0ebe39bb26c8e8b4503168a849265a (diff) | |
| download | seaweedfs-df5e54e02af60f6a1537cd5853def4dad42932bc.tar.xz seaweedfs-df5e54e02af60f6a1537cd5853def4dad42932bc.zip | |
Merge pull request #224 from tnextday/feature/chunked-file-support
Feature/chunked file support
Diffstat (limited to 'go/storage/needle.go')
| -rw-r--r-- | go/storage/needle.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/go/storage/needle.go b/go/storage/needle.go index 04a9dc78d..32ebdae7d 100644 --- a/go/storage/needle.go +++ b/go/storage/needle.go @@ -15,6 +15,7 @@ import ( "github.com/chrislusf/seaweedfs/go/glog" "github.com/chrislusf/seaweedfs/go/images" "github.com/chrislusf/seaweedfs/go/util" + "github.com/chrislusf/seaweedfs/go/operation" ) const ( @@ -52,7 +53,7 @@ func (n *Needle) String() (str string) { return } -func ParseUpload(r *http.Request) (fileName string, data []byte, mimeType string, isGzipped bool, modifiedTime uint64, ttl *TTL, e error) { +func ParseUpload(r *http.Request) (fileName string, data []byte, mimeType string, isGzipped bool, modifiedTime uint64, ttl *TTL, isChunkedFile bool, e error) { form, fe := r.MultipartReader() if fe != nil { glog.V(0).Infoln("MultipartReader [ERROR]", fe) @@ -117,8 +118,8 @@ func ParseUpload(r *http.Request) (fileName string, data []byte, mimeType string } if part.Header.Get("Content-Encoding") == "gzip" { isGzipped = true - } else if IsGzippable(ext, mtype) { - if data, e = GzipData(data); e != nil { + } else if operation.IsGzippable(ext, mtype) { + if data, e = operation.GzipData(data); e != nil { return } isGzipped = true @@ -132,12 +133,13 @@ func ParseUpload(r *http.Request) (fileName string, data []byte, mimeType string } modifiedTime, _ = strconv.ParseUint(r.FormValue("ts"), 10, 64) ttl, _ = ReadTTL(r.FormValue("ttl")) + isChunkedFile, _ = strconv.ParseBool(r.FormValue("cm")) return } func NewNeedle(r *http.Request, fixJpgOrientation bool) (n *Needle, e error) { - fname, mimeType, isGzipped := "", "", false + fname, mimeType, isGzipped, isChunkedFile := "", "", false, false n = new(Needle) - fname, n.Data, mimeType, isGzipped, n.LastModified, n.Ttl, e = ParseUpload(r) + fname, n.Data, mimeType, isGzipped, n.LastModified, n.Ttl, isChunkedFile, e = ParseUpload(r) if e != nil { return } @@ -160,6 +162,10 @@ func NewNeedle(r *http.Request, fixJpgOrientation bool) (n *Needle, e error) { n.SetHasTtl() } + if isChunkedFile { + n.SetChunkManifest() + } + if fixJpgOrientation { loweredName := strings.ToLower(fname) if mimeType == "image/jpeg" || strings.HasSuffix(loweredName, ".jpg") || strings.HasSuffix(loweredName, ".jpeg") { |
