由于阿里那边没有提供golang示例只有自己写一个,如果发现问题希望给予纠正。
配置信息自己替换。
调用方法
Putobject("4.txt", []byte("123123fasdfasdfadfadfasfasdfsadf"))
package oss
import (
"bytes"
"crypto/hmac"
"crypto/sha1"
"encoding/base64"
"fmt"
"io/ioutil"
"mime"
"net/http"
"path/filepath"
"time"
)
func authorization(accesskeysecret, method, filemd5, filetype, date, CanonicalizedOSSHeaders, CanonicalizedResource string) string {
h := hmac.New(sha1.New, []byte(accesskeysecret))
s := fmt.Sprintf("%v\n%v\n%v\n%v\n%v%v", method, filemd5, filetype, date, CanonicalizedOSSHeaders, CanonicalizedResource)
h.Write([]byte(s))
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
var client = &http.Client{Timeout: 20 * time.Secon