mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
verify content-md5 in header
if upload content by s3 client and set content-md5 in header,then will verify recived and saved content,if not equal delete thos chunks
This commit is contained in:
parent
6c1ce18541
commit
9e03b916d8
|
@ -99,6 +99,11 @@ func (fs *FilerServer) doPostAutoChunk(ctx context.Context, w http.ResponseWrite
|
|||
}
|
||||
|
||||
md5bytes = md5Hash.Sum(nil)
|
||||
headerMd5 := r.Header.Get("Content-Md5")
|
||||
if headerMd5 != "" && !(util.Base64Encode(md5bytes) == headerMd5 || fmt.Sprintf("%x", md5bytes) == headerMd5) {
|
||||
fs.filer.DeleteChunks(fileChunks)
|
||||
return nil, nil, errors.New("The Content-Md5 you specified did not match what we received.")
|
||||
}
|
||||
filerResult, replyerr = fs.saveMetaData(ctx, r, fileName, contentType, so, md5bytes, fileChunks, chunkOffset, smallContent)
|
||||
if replyerr != nil {
|
||||
fs.filer.DeleteChunks(fileChunks)
|
||||
|
@ -121,6 +126,11 @@ func (fs *FilerServer) doPutAutoChunk(ctx context.Context, w http.ResponseWriter
|
|||
}
|
||||
|
||||
md5bytes = md5Hash.Sum(nil)
|
||||
headerMd5 := r.Header.Get("Content-Md5")
|
||||
if headerMd5 != "" && !(util.Base64Encode(md5bytes) == headerMd5 || fmt.Sprintf("%x", md5bytes) == headerMd5) {
|
||||
fs.filer.DeleteChunks(fileChunks)
|
||||
return nil, nil, errors.New("The Content-Md5 you specified did not match what we received.")
|
||||
}
|
||||
filerResult, replyerr = fs.saveMetaData(ctx, r, fileName, contentType, so, md5bytes, fileChunks, chunkOffset, smallContent)
|
||||
if replyerr != nil {
|
||||
fs.filer.DeleteChunks(fileChunks)
|
||||
|
|
Loading…
Reference in a new issue