|
|
@ -39,16 +39,26 @@ func (donut Donut) Write(header Header, object io.Reader) error { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// write header length
|
|
|
|
// prefix consists of a version number and a length
|
|
|
|
var headerLengthBuffer bytes.Buffer |
|
|
|
var headerPrefixBuffer bytes.Buffer |
|
|
|
headerLength := headerBuffer.Len() |
|
|
|
// write version
|
|
|
|
err = binary.Write(&headerLengthBuffer, binary.LittleEndian, headerLength) |
|
|
|
var version int |
|
|
|
|
|
|
|
version = 1 |
|
|
|
|
|
|
|
err = binary.Write(&headerPrefixBuffer, binary.LittleEndian, version) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// write header length
|
|
|
|
// write length
|
|
|
|
io.Copy(&newObjectBuffer, &headerLengthBuffer) |
|
|
|
var headerLength int |
|
|
|
|
|
|
|
headerLength = headerBuffer.Len() |
|
|
|
|
|
|
|
err = binary.Write(&headerPrefixBuffer, binary.LittleEndian, headerLength) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// write header prefix
|
|
|
|
|
|
|
|
io.Copy(&newObjectBuffer, &headerPrefixBuffer) |
|
|
|
|
|
|
|
|
|
|
|
// write header
|
|
|
|
// write header
|
|
|
|
io.Copy(&newObjectBuffer, &headerBuffer) |
|
|
|
io.Copy(&newObjectBuffer, &headerBuffer) |
|
|
|