aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weed/operation/assign_file_id.go1
-rw-r--r--weed/server/filer_server_handlers_write.go12
-rw-r--r--weed/server/filer_server_handlers_write_autochunk.go11
3 files changed, 22 insertions, 2 deletions
diff --git a/weed/operation/assign_file_id.go b/weed/operation/assign_file_id.go
index 135c5201e..c2f5a806d 100644
--- a/weed/operation/assign_file_id.go
+++ b/weed/operation/assign_file_id.go
@@ -137,6 +137,7 @@ type StorageOption struct {
TtlSeconds int32
Fsync bool
VolumeGrowthCount uint32
+ SaveInside bool
}
func (so *StorageOption) TtlString() string {
diff --git a/weed/server/filer_server_handlers_write.go b/weed/server/filer_server_handlers_write.go
index 11019c7d2..898975d14 100644
--- a/weed/server/filer_server_handlers_write.go
+++ b/weed/server/filer_server_handlers_write.go
@@ -87,6 +87,7 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request, conte
query.Get("dataCenter"),
query.Get("rack"),
query.Get("dataNode"),
+ query.Get("saveInside"),
)
if err != nil {
if err == ErrReadOnly {
@@ -103,6 +104,10 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request, conte
so.DiskType = fs.option.DiskType
}
+ if strings.HasPrefix(r.URL.Path, "/etc") {
+ so.SaveInside = true
+ }
+
if query.Has("mv.from") {
fs.move(ctx, w, r, so)
} else {
@@ -246,7 +251,7 @@ func (fs *FilerServer) detectStorageOption(requestURI, qCollection, qReplication
}, nil
}
-func (fs *FilerServer) detectStorageOption0(requestURI, qCollection, qReplication string, qTtl string, diskType string, fsync string, dataCenter, rack, dataNode string) (*operation.StorageOption, error) {
+func (fs *FilerServer) detectStorageOption0(requestURI, qCollection, qReplication string, qTtl string, diskType string, fsync string, dataCenter, rack, dataNode, saveInside string) (*operation.StorageOption, error) {
ttl, err := needle.ReadTTL(qTtl)
if err != nil {
@@ -260,6 +265,11 @@ func (fs *FilerServer) detectStorageOption0(requestURI, qCollection, qReplicatio
} else if fsync == "true" {
so.Fsync = true
}
+ if saveInside == "true" {
+ so.SaveInside = true
+ } else {
+ so.SaveInside = false
+ }
}
return so, err
diff --git a/weed/server/filer_server_handlers_write_autochunk.go b/weed/server/filer_server_handlers_write_autochunk.go
index 6732db195..27519bee7 100644
--- a/weed/server/filer_server_handlers_write_autochunk.go
+++ b/weed/server/filer_server_handlers_write_autochunk.go
@@ -1,6 +1,7 @@
package weed_server
import (
+ "bytes"
"context"
"fmt"
//"github.com/seaweedfs/seaweedfs/weed/s3api"
@@ -64,7 +65,6 @@ func (fs *FilerServer) autoChunk(ctx context.Context, w http.ResponseWriter, r *
}
func (fs *FilerServer) doPostAutoChunk(ctx context.Context, w http.ResponseWriter, r *http.Request, chunkSize int32, contentLength int64, so *operation.StorageOption) (filerResult *FilerPostResult, md5bytes []byte, replyerr error) {
-
multipartReader, multipartReaderErr := r.MultipartReader()
if multipartReaderErr != nil {
return nil, nil, multipartReaderErr
@@ -84,6 +84,15 @@ func (fs *FilerServer) doPostAutoChunk(ctx context.Context, w http.ResponseWrite
contentType = ""
}
+ if so.SaveInside {
+ buf := bufPool.Get().(*bytes.Buffer)
+ buf.Reset()
+ buf.ReadFrom(part1)
+ filerResult, replyerr = fs.saveMetaData(ctx, r, fileName, contentType, so, nil, nil, 0, buf.Bytes())
+ bufPool.Put(buf)
+ return
+ }
+
fileChunks, md5Hash, chunkOffset, err, smallContent := fs.uploadReaderToChunks(w, r, part1, chunkSize, fileName, contentType, contentLength, so)
if err != nil {
return nil, nil, err