- Write decoded bytes without padding

Signed-off-by: Natalie Arellano <narellano@pivotal.io>
pull/4748/head
Mark DeLillo 9 years ago committed by Natalie Arellano
parent 0614fc234f
commit 9a16b6768e

@ -203,9 +203,10 @@ func (d *Base64Pipe) ReadFrom(r io.Reader) (int64, error) {
func (d *Base64Pipe) Write(p []byte) (int, error) {
dst := make([]byte, base64.StdEncoding.DecodedLen(len(p)))
if _, err := base64.StdEncoding.Decode(dst, p); err != nil {
decodedBytes, err := base64.StdEncoding.Decode(dst, p)
if err != nil {
return 0, err
}
return d.w.Write(dst)
return d.w.Write(dst[0:decodedBytes])
}

@ -108,7 +108,7 @@ func TestUpload(t *testing.T) {
if err != nil {
t.Fatalf("error downloading file: %s", err)
}
downloadedPayload := strings.TrimRight(dest.String(), "\x00")
downloadedPayload := dest.String()
if downloadedPayload != PAYLOAD {
t.Fatalf("files are not equal: expected [%s] length: %v, got [%s] length %v", PAYLOAD, len(PAYLOAD), downloadedPayload, len(downloadedPayload))

Loading…
Cancel
Save