golang上传文件到OSS

package main

import (
	"crypto/hmac"
	"crypto/sha1"
	"encoding/base64"
	"errors"
	"fmt"
	"io/ioutil"
	"net/http"
	"os"
	"time"
)

const AccessKeyID = "0000"
const AccessKeySecret = "0000"

const Bucket = "bbbb"
const BucketUrl = "https://bbbb.oss-cn-beijing.aliyuncs.com"

var datetime string = time.Now().UTC().Format(http.TimeFormat)

func Sign(dest string) string {
	h := hmac.New(sha1.New, []byte(AccessKeySecret))
	h.Write([]byte("PUT\n\napplication/octet-stream\n" + datetime + "\n/" + Bucket + dest))
	return "OSS " + AccessKeyID + ":" + base64.StdEncoding.EncodeToString(h.Sum(nil))
}

func Upload(file string, dest string) error {

	f, err := os.Open(file)
	if err != nil {
		return err
	}
	defer f.Close()

	request, err := http.NewRequest("PUT", BucketUrl+dest, f)
	if err != nil {
		return err
	}

	request.Header.Add("Date", datetime)
	request.Header.Add("Authorization", Sign(dest))
	request.Header.Add("Content-Type", "application/octet-stream")

	client := &http.Client{}
	response, err := client.Do(request)
	if err != nil {
		return err
	}
	defer response.Body.Close()

	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return err
	}

	if response.StatusCode == 200 {
		return nil
	} else {
		return errors.New(string(body))
	}

}

func main() {
	up := Upload("02.zip", "/08.zip")
	fmt.Println(up)
}