本文整理汇总了Golang中github.com/datacratic/aws-sdk-go/service/s3.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExampleS3_PutBucketTagging
func ExampleS3_PutBucketTagging() {
svc := s3.New(nil)
params := &s3.PutBucketTaggingInput{
Bucket: aws.String("BucketName"), // Required
Tagging: &s3.Tagging{ // Required
TagSet: []*s3.Tag{ // Required
&s3.Tag{ // Required
Key: aws.String("ObjectKey"), // Required
Value: aws.String("Value"), // Required
},
// More values...
},
},
}
resp, err := svc.PutBucketTagging(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
} else if err != nil {
// A non-service error occurred.
panic(err)
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例2: ExampleS3_CreateBucket
func ExampleS3_CreateBucket() {
svc := s3.New(nil)
params := &s3.CreateBucketInput{
Bucket: aws.String("BucketName"), // Required
ACL: aws.String("BucketCannedACL"),
CreateBucketConfiguration: &s3.CreateBucketConfiguration{
LocationConstraint: aws.String("BucketLocationConstraint"),
},
GrantFullControl: aws.String("GrantFullControl"),
GrantRead: aws.String("GrantRead"),
GrantReadACP: aws.String("GrantReadACP"),
GrantWrite: aws.String("GrantWrite"),
GrantWriteACP: aws.String("GrantWriteACP"),
}
resp, err := svc.CreateBucket(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
} else if err != nil {
// A non-service error occurred.
panic(err)
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例3: ExampleS3_UploadPart
func ExampleS3_UploadPart() {
svc := s3.New(nil)
params := &s3.UploadPartInput{
Bucket: aws.String("BucketName"), // Required
Key: aws.String("ObjectKey"), // Required
PartNumber: aws.Long(1), // Required
UploadID: aws.String("MultipartUploadId"), // Required
Body: bytes.NewReader([]byte("PAYLOAD")),
ContentLength: aws.Long(1),
RequestPayer: aws.String("RequestPayer"),
SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
SSECustomerKey: aws.String("SSECustomerKey"),
SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
}
resp, err := svc.UploadPart(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
} else if err != nil {
// A non-service error occurred.
panic(err)
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例4: ExampleS3_PutBucketReplication
func ExampleS3_PutBucketReplication() {
svc := s3.New(nil)
params := &s3.PutBucketReplicationInput{
Bucket: aws.String("BucketName"), // Required
ReplicationConfiguration: &s3.ReplicationConfiguration{ // Required
Role: aws.String("Role"), // Required
Rules: []*s3.ReplicationRule{ // Required
&s3.ReplicationRule{ // Required
Destination: &s3.Destination{ // Required
Bucket: aws.String("BucketName"), // Required
},
Prefix: aws.String("Prefix"), // Required
Status: aws.String("ReplicationRuleStatus"), // Required
ID: aws.String("ID"),
},
// More values...
},
},
}
resp, err := svc.PutBucketReplication(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
} else if err != nil {
// A non-service error occurred.
panic(err)
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例5: ExampleS3_ListObjectVersions
func ExampleS3_ListObjectVersions() {
svc := s3.New(nil)
params := &s3.ListObjectVersionsInput{
Bucket: aws.String("BucketName"), // Required
Delimiter: aws.String("Delimiter"),
EncodingType: aws.String("EncodingType"),
KeyMarker: aws.String("KeyMarker"),
MaxKeys: aws.Long(1),
Prefix: aws.String("Prefix"),
VersionIDMarker: aws.String("VersionIdMarker"),
}
resp, err := svc.ListObjectVersions(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
} else if err != nil {
// A non-service error occurred.
panic(err)
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例6: ExampleS3_DeleteObjects
func ExampleS3_DeleteObjects() {
svc := s3.New(nil)
params := &s3.DeleteObjectsInput{
Bucket: aws.String("BucketName"), // Required
Delete: &s3.Delete{ // Required
Objects: []*s3.ObjectIdentifier{ // Required
&s3.ObjectIdentifier{ // Required
Key: aws.String("ObjectKey"), // Required
VersionID: aws.String("ObjectVersionId"),
},
// More values...
},
Quiet: aws.Boolean(true),
},
MFA: aws.String("MFA"),
RequestPayer: aws.String("RequestPayer"),
}
resp, err := svc.DeleteObjects(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
} else if err != nil {
// A non-service error occurred.
panic(err)
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例7: ExampleS3_HeadObject
func ExampleS3_HeadObject() {
svc := s3.New(nil)
params := &s3.HeadObjectInput{
Bucket: aws.String("BucketName"), // Required
Key: aws.String("ObjectKey"), // Required
IfMatch: aws.String("IfMatch"),
IfModifiedSince: aws.Time(time.Now()),
IfNoneMatch: aws.String("IfNoneMatch"),
IfUnmodifiedSince: aws.Time(time.Now()),
Range: aws.String("Range"),
RequestPayer: aws.String("RequestPayer"),
SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
SSECustomerKey: aws.String("SSECustomerKey"),
SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
VersionID: aws.String("ObjectVersionId"),
}
resp, err := svc.HeadObject(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
} else if err != nil {
// A non-service error occurred.
panic(err)
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例8: ExampleS3_UploadPartCopy
func ExampleS3_UploadPartCopy() {
svc := s3.New(nil)
params := &s3.UploadPartCopyInput{
Bucket: aws.String("BucketName"), // Required
CopySource: aws.String("CopySource"), // Required
Key: aws.String("ObjectKey"), // Required
PartNumber: aws.Long(1), // Required
UploadID: aws.String("MultipartUploadId"), // Required
CopySourceIfMatch: aws.String("CopySourceIfMatch"),
CopySourceIfModifiedSince: aws.Time(time.Now()),
CopySourceIfNoneMatch: aws.String("CopySourceIfNoneMatch"),
CopySourceIfUnmodifiedSince: aws.Time(time.Now()),
CopySourceRange: aws.String("CopySourceRange"),
CopySourceSSECustomerAlgorithm: aws.String("CopySourceSSECustomerAlgorithm"),
CopySourceSSECustomerKey: aws.String("CopySourceSSECustomerKey"),
CopySourceSSECustomerKeyMD5: aws.String("CopySourceSSECustomerKeyMD5"),
RequestPayer: aws.String("RequestPayer"),
SSECustomerAlgorithm: aws.String("SSECustomerAlgorithm"),
SSECustomerKey: aws.String("SSECustomerKey"),
SSECustomerKeyMD5: aws.String("SSECustomerKeyMD5"),
}
resp, err := svc.UploadPartCopy(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
} else if err != nil {
// A non-service error occurred.
panic(err)
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例9: ExampleS3_RestoreObject
func ExampleS3_RestoreObject() {
svc := s3.New(nil)
params := &s3.RestoreObjectInput{
Bucket: aws.String("BucketName"), // Required
Key: aws.String("ObjectKey"), // Required
RequestPayer: aws.String("RequestPayer"),
RestoreRequest: &s3.RestoreRequest{
Days: aws.Long(1), // Required
},
VersionID: aws.String("ObjectVersionId"),
}
resp, err := svc.RestoreObject(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
} else if err != nil {
// A non-service error occurred.
panic(err)
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例10: ExampleS3_CompleteMultipartUpload
func ExampleS3_CompleteMultipartUpload() {
svc := s3.New(nil)
params := &s3.CompleteMultipartUploadInput{
Bucket: aws.String("BucketName"), // Required
Key: aws.String("ObjectKey"), // Required
UploadID: aws.String("MultipartUploadId"), // Required
MultipartUpload: &s3.CompletedMultipartUpload{
Parts: []*s3.CompletedPart{
&s3.CompletedPart{ // Required
ETag: aws.String("ETag"),
PartNumber: aws.Long(1),
},
// More values...
},
},
RequestPayer: aws.String("RequestPayer"),
}
resp, err := svc.CompleteMultipartUpload(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
} else if err != nil {
// A non-service error occurred.
panic(err)
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
示例11: TestNoPopulateLocationConstraintIfClassic
func TestNoPopulateLocationConstraintIfClassic(t *testing.T) {
s := s3.New(baseConfig.Merge(&aws.Config{Region: "us-east-1"}))
req, _ := s.CreateBucketRequest(&s3.CreateBucketInput{
Bucket: aws.String("bucket"),
})
err := req.Build()
assert.NoError(t, err)
assert.Equal(t, 0, len(awsutil.ValuesAtPath(req.Params, "CreateBucketConfiguration.LocationConstraint")))
}
示例12: TestNoPopulateLocationConstraintIfProvided
func TestNoPopulateLocationConstraintIfProvided(t *testing.T) {
s := s3.New(baseConfig)
req, _ := s.CreateBucketRequest(&s3.CreateBucketInput{
Bucket: aws.String("bucket"),
CreateBucketConfiguration: &s3.CreateBucketConfiguration{},
})
err := req.Build()
assert.NoError(t, err)
assert.Equal(t, 0, len(awsutil.ValuesAtPath(req.Params, "CreateBucketConfiguration.LocationConstraint")))
}
示例13: TestPopulateLocationConstraint
func TestPopulateLocationConstraint(t *testing.T) {
s := s3.New(baseConfig)
in := &s3.CreateBucketInput{
Bucket: aws.String("bucket"),
}
req, _ := s.CreateBucketRequest(in)
err := req.Build()
assert.NoError(t, err)
assert.Equal(t, "mock-region", awsutil.ValuesAtPath(req.Params, "CreateBucketConfiguration.LocationConstraint")[0])
assert.Nil(t, in.CreateBucketConfiguration) // don't modify original params
}
示例14: TestMD5InDeleteObjects
func TestMD5InDeleteObjects(t *testing.T) {
svc := s3.New(baseConfig)
req, _ := svc.DeleteObjectsRequest(&s3.DeleteObjectsInput{
Bucket: aws.String("bucketname"),
Delete: &s3.Delete{
Objects: []*s3.ObjectIdentifier{
&s3.ObjectIdentifier{Key: aws.String("key")},
},
},
})
assertMD5(t, req)
}
示例15: TestMD5InPutBucketTagging
func TestMD5InPutBucketTagging(t *testing.T) {
svc := s3.New(baseConfig)
req, _ := svc.PutBucketTaggingRequest(&s3.PutBucketTaggingInput{
Bucket: aws.String("bucketname"),
Tagging: &s3.Tagging{
TagSet: []*s3.Tag{
&s3.Tag{Key: aws.String("KEY"), Value: aws.String("VALUE")},
},
},
})
assertMD5(t, req)
}