|
|
@ -4,13 +4,14 @@ import ( |
|
|
|
"bytes" |
|
|
|
"context" |
|
|
|
"fmt" |
|
|
|
"sync" |
|
|
|
"sync/atomic" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/glog" |
|
|
|
"github.com/chrislusf/seaweedfs/weed/operation" |
|
|
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" |
|
|
|
"sync" |
|
|
|
"github.com/chrislusf/seaweedfs/weed/security" |
|
|
|
) |
|
|
|
|
|
|
|
type ContinuousDirtyPages struct { |
|
|
@ -164,6 +165,7 @@ func (pages *ContinuousDirtyPages) saveExistingPagesToStorage(ctx context.Contex |
|
|
|
func (pages *ContinuousDirtyPages) saveToStorage(ctx context.Context, buf []byte, offset int64) (*filer_pb.FileChunk, error) { |
|
|
|
|
|
|
|
var fileId, host string |
|
|
|
var auth security.EncodedJwt |
|
|
|
|
|
|
|
if err := pages.f.wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error { |
|
|
|
|
|
|
@ -181,7 +183,7 @@ func (pages *ContinuousDirtyPages) saveToStorage(ctx context.Context, buf []byte |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
fileId, host = resp.FileId, resp.Url |
|
|
|
fileId, host, auth = resp.FileId, resp.Url, security.EncodedJwt(resp.Auth) |
|
|
|
|
|
|
|
return nil |
|
|
|
}); err != nil { |
|
|
@ -190,7 +192,7 @@ func (pages *ContinuousDirtyPages) saveToStorage(ctx context.Context, buf []byte |
|
|
|
|
|
|
|
fileUrl := fmt.Sprintf("http://%s/%s", host, fileId) |
|
|
|
bufReader := bytes.NewReader(buf) |
|
|
|
uploadResult, err := operation.Upload(fileUrl, pages.f.Name, bufReader, false, "application/octet-stream", nil, "") |
|
|
|
uploadResult, err := operation.Upload(fileUrl, pages.f.Name, bufReader, false, "application/octet-stream", nil, auth) |
|
|
|
if err != nil { |
|
|
|
glog.V(0).Infof("upload data %v to %s: %v", pages.f.Name, fileUrl, err) |
|
|
|
return nil, fmt.Errorf("upload data: %v", err) |
|
|
|