-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dec10ed
commit ca15fd2
Showing
8 changed files
with
291 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package sample | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/aliyun/aliyun-oss-go-sdk/oss" | ||
) | ||
|
||
// BucketResponseHeaderSample shows how to set, get and delete the bucket's response header. | ||
func BucketResponseHeaderSample() { | ||
// New client | ||
client, err := oss.New(endpoint, accessID, accessKey) | ||
if err != nil { | ||
HandleError(err) | ||
} | ||
|
||
// Create the bucket with default parameters | ||
err = client.CreateBucket(bucketName) | ||
if err != nil { | ||
HandleError(err) | ||
} | ||
|
||
// Set bucket's response header. | ||
reqHeader := oss.PutBucketResponseHeader{ | ||
Rule: []oss.BucketResponseHeaderRule{ | ||
{ | ||
Name: "name1", | ||
Filters: []string{ | ||
"Put", "GetObject", | ||
}, | ||
HideHeaders: []string{"Last-Modified"}, | ||
}, | ||
{ | ||
Name: "name2", | ||
Filters: []string{ | ||
"*", | ||
}, | ||
HideHeaders: []string{"Last-Modified"}, | ||
}, | ||
}, | ||
} | ||
err = client.PutBucketResponseHeader(bucketName, reqHeader) | ||
if err != nil { | ||
HandleError(err) | ||
} | ||
|
||
fmt.Println("Bucket Response Header Set Success!") | ||
|
||
// Get bucket's response header. | ||
header, err := client.GetBucketResponseHeader(bucketName) | ||
if err != nil { | ||
HandleError(err) | ||
} | ||
for _, rule := range header.Rule { | ||
fmt.Printf("Rule Name:%#v\n", rule.Name) | ||
if len(rule.Filters) > 0 { | ||
for _, filter := range rule.Filters { | ||
fmt.Printf("Rule Filter:%#v\n", filter) | ||
} | ||
} | ||
if len(rule.HideHeaders) > 0 { | ||
for _, hide := range rule.HideHeaders { | ||
fmt.Printf("Rule Hide Headers:%#v\n", hide) | ||
} | ||
} | ||
} | ||
|
||
// Delete bucket's response header. | ||
err = client.DeleteBucketResponseHeader(bucketName) | ||
if err != nil { | ||
HandleError(err) | ||
} | ||
fmt.Println("Bucket Response Header Delete Success!") | ||
|
||
fmt.Println("BucketResponseHeaderSample completed") | ||
} |