本文整理匯總了Golang中github.com/cz-it/aliyun-oss-golang-sdk/ossapi.Init函數的典型用法代碼示例。如果您正苦於以下問題:Golang Init函數的具體用法?Golang Init怎麽用?Golang Init使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Init函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestGetService
func TestGetService(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
if buckets, err := QueryBucketsDefault(); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
fmt.Println(buckets)
t.Log("[SUCC]:GetService")
}
fmt.Println("+++++++++++++++Get Service With+++++++++++")
if buckets, err := QueryBuckets("aa", "b&afds=safsd?asfsab", 10); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
fmt.Println(buckets)
t.Log("[SUCC]:GetService")
}
fmt.Println("+++++++++++++++With Init Error+++++++++++")
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1sfasdfs") {
t.Fail()
}
if buckets, err := QueryBucketsDefault(); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
fmt.Println(buckets)
t.Log("[SUCC]:GetService")
}
}
示例2: TestCopyObject
func TestCopyObject(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
copyInfo := &CopyInfo{
ObjectName: "test2.html",
BucketName: "test-object-hz",
Location: bucket.LHangzhou,
Source: "/test-object-hz/test"}
if info, err := Copy(copyInfo, nil); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("CopyObject Success")
fmt.Println(info)
}
conInfo := &CopyConditionInfo{}
if info, err := Copy(copyInfo, conInfo); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("CopyObject Success")
fmt.Println(info)
}
}
示例3: TestCreateObject
func TestCreateObject(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
objInfo := &Info{
CacheControl: "no-cache",
ContentDisposition: "attachment;filename=oss_download.jpg",
ContentEncoding: "utf-8",
Expires: "Fri, 28 Feb 2012 05:38:42 GMT",
Encryption: "AES256",
ACL: bucket.PPrivate,
Body: []byte("<html><head></head><body>test</body></html>"),
Type: "text/html"}
if err := Create("test", "test-object-hz", bucket.LHangzhou, objInfo); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("PutObject Success!")
}
if err := Create("test2", "test-object-hz", bucket.LHangzhou, objInfo); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("PutObject Success!")
}
}
示例4: TestCompleteMultipartUpload
func TestCompleteMultipartUpload(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
initInfo := &InitInfo{
CacheControl: "no-cache",
ContentDisposition: "attachment;filename=oss_download.jpg",
ContentEncoding: "utf-8",
Expires: "Fri, 28 Feb 2012 05:38:42 GMT",
Encryption: "AES256"}
var info *InitRstInfo
var err *ossapi.Error
if info, err = Init("a.c", "test-mupload", bucket.LHangzhou, initInfo); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("Init Multiple Upload Success!")
fmt.Println(info)
}
var partData []byte
for i := 0; i < 10250; i++ {
partData = append(partData, "1234567890"...)
}
partInfo := &UploadPartInfo{
ObjectName: "a.c",
BucketName: "test-mupload",
Location: bucket.LHangzhou,
UploadID: info.UploadId,
PartNumber: 1,
Data: partData[:100*1024],
CntType: "text/html"}
var i1 PartInfo
if info, err := Append(partInfo); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
i1.ETag = info.Etag
i1.PartNumber = 1
t.Log("UploadPart Success!")
}
partInfo.PartNumber = 2
var i2 PartInfo
if info, err := Append(partInfo); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
i2.ETag = info.Etag
i2.PartNumber = 2
t.Log("UploadPart Success!")
}
partsInfo := &PartsInfo{Part: []PartInfo{i1, i2}}
if info, err := Complete("a.c", "test-mupload", bucket.LHangzhou, info.UploadId, partsInfo); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log(" CompleteMultipartUpload Success!")
fmt.Println(info)
}
}
示例5: TestGetBucketACL
func TestGetBucketACL(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
if info, err := QueryACL("test-put-bucket2", LHangzhou); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
fmt.Println(info)
}
}
示例6: TestSetBucketWebsite
func TestSetBucketWebsite(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
if err := SetWebsite("test-put-bucket4", LBeijing, "index.html", ""); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("SetBucketWebSite Success")
}
}
示例7: TestDeleteBucketCORS
func TestDeleteBucketCORS(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
if err := Delete("test-cors", bucket.LHangzhou); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("DelteBucketCORS Success")
}
}
示例8: TestDeleteBucketLifecycle
func TestDeleteBucketLifecycle(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
if err := DeleteLifecycle("test-put-bucket3", LBeijing); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("DeleteBucketLifecycle Success")
}
}
示例9: TestOpenLogging
func TestOpenLogging(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
if err := OpenLogging("test-put-bucket", LHangzhou, "test-put-bucket", "test-2-"); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("Open Bucket Log Success")
}
}
示例10: TestListMultipartUploads
func TestListMultipartUploads(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
if info, err := QueryObjects("test-object-hz", bucket.LHangzhou, nil); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("Init Multiple Upload Success!")
fmt.Println(info)
}
}
示例11: TestSetObjectACL
func TestSetObjectACL(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
if err := SetACL("acl", "test-object-hz", bucket.LHangzhou, bucket.PPublicRW); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("PutObjectACL Success!")
}
}
示例12: TestGetBucket
func TestGetBucket(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
if info, err := QueryObjects("test-put-bucket3", LBeijing, "", "", "", "", 0); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("GetBucket Success")
fmt.Println(info)
}
}
示例13: TestSetBucketLifecycle
func TestSetBucketLifecycle(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
rules := []RuleInfo{RuleInfo{Prefix: "nimei", Status: LifecycleStatsEnable, Expiration: ExpirationDaysInfo{2}}}
if err := SetLifecycle("test-put-bucket3", LBeijing, rules); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("SetBucketLiecycle Success")
}
}
示例14: TestOptionObject
func TestOptionObject(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
optionInfo := &OptionReqInfo{Origin: "www.qq.com", Method: "GET", Headers: "authorization"}
if info, err := Option("app.py", "test-cors", bucket.LHangzhou, optionInfo); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("OptionObject Success")
fmt.Println(info)
}
}
示例15: TestQueryObject
func TestQueryObject(t *testing.T) {
if nil != ossapi.Init("v8P430U3UcILP6KA", "EB9v8yL2aM07YOgtO1BdfrXtdxa4A1") {
t.Fail()
}
if info, err := Query("acl", "test-object-hz", bucket.LHangzhou, nil, nil); err != nil {
fmt.Println(err.ErrNo, err.HTTPStatus, err.ErrMsg, err.ErrDetailMsg)
} else {
t.Log("GetObjectACL Success!")
fmt.Println(info)
}
}