当前位置: 首页>>代码示例>>Golang>>正文


Golang s3.S3类代码示例

本文整理汇总了Golang中github.com/ks3sdklib/aws-sdk-go/service/s3.S3的典型用法代码示例。如果您正苦于以下问题:Golang S3类的具体用法?Golang S3怎么用?Golang S3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了S3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: getObjectAcl

func getObjectAcl(c *s3.S3) {
	putObject(c)
	key := "aws/config.go"
	out, err := c.GetObjectACL(
		&s3.GetObjectACLInput{
			Bucket: &bucket,
			Key:    &key,
		},
	)
	if err != nil {
		panic(err)
	}
	grants := out.Grants
	for i := 0; i < len(grants); i++ {
		grant := grants[i]
		grantee := grant.Grantee
		if grantee.DisplayName != nil {
			fmt.Println(*grantee.DisplayName)
		}
		if grantee.ID != nil {
			fmt.Println(*grantee.ID)
		}
		if grantee.Type != nil {
			fmt.Println(*grantee.Type)
		}
		if grantee.URI != nil {
			fmt.Println(*grantee.URI)
		}
		if grant.Permission != nil {
			fmt.Println(*grant.Permission)
		}
		fmt.Println("---------")
	}
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:34,代码来源:test.go

示例2: runTests

func runTests(t *testing.T, svc *s3.S3, tests []s3BucketTest) {
	for _, test := range tests {
		req, _ := svc.ListObjectsRequest(&s3.ListObjectsInput{Bucket: &test.bucket})
		req.Build()
		assert.Equal(t, test.url, req.HTTPRequest.URL.String())
	}
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:7,代码来源:host_style_bucket_test.go

示例3: putBucket

func putBucket(c *s3.S3) {
	acl := "public-read"
	_, err := c.CreateBucket(&s3.CreateBucketInput{
		ACL:    &acl,
		Bucket: &bucket,
	})
	checkError("put bucket", err, "BucketAlreadyExists")
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:8,代码来源:test.go

示例4: deleteBucket

func deleteBucket(c *s3.S3) {
	putObject(c)
	_, err := c.DeleteBucket(
		&s3.DeleteBucketInput{
			Bucket: &bucket,
		},
	)
	checkError("delete bucket", err, "BucketNotEmpty")
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:9,代码来源:test.go

示例5: getBucketAcl

func getBucketAcl(c *s3.S3) {
	_, err := c.GetBucketACL(
		&s3.GetBucketACLInput{
			Bucket: &bucket,
		},
	)
	if err != nil {
		panic(err)
	}
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:10,代码来源:test.go

示例6: putBucketAcl

func putBucketAcl(c *s3.S3) {
	acl := "public-read"
	out, err := c.PutBucketACL(&s3.PutBucketACLInput{
		ACL:    &acl,
		Bucket: &bucket,
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(out)
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:11,代码来源:test.go

示例7: headBucket

func headBucket(c *s3.S3) {
	out, err := c.HeadBucket(
		&s3.HeadBucketInput{
			Bucket: &bucket,
		},
	)
	if err != nil {
		panic(err)
	}
	fmt.Println(out)
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:11,代码来源:test.go

示例8: getBucketLogging

func getBucketLogging(c *s3.S3) {
	out, err := c.GetBucketLogging(
		&s3.GetBucketLoggingInput{
			Bucket: &bucket,
		},
	)
	if err != nil {
		panic(err)
	}
	fmt.Println(*out.LoggingEnabled.TargetBucket)
	fmt.Println(*out.LoggingEnabled.TargetPrefix)
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:12,代码来源:test.go

示例9: getObjectPresignedUrl

func getObjectPresignedUrl(c *s3.S3) {
	key := "aws/config.go"
	content := "text/html"
	url, _ := c.GetObjectPresignedUrl(
		&s3.GetObjectInput{
			Bucket:              &bucket,
			Key:                 &key,
			ResponseContentType: &content,
		},
		1444370289000000000,
	)
	fmt.Println(url)
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:13,代码来源:test.go

示例10: deleteObject

func deleteObject(c *s3.S3) {
	putObject(c)
	key := "aws/config.go"
	_, err := c.DeleteObject(
		&s3.DeleteObjectInput{
			Bucket: &bucket,
			Key:    &key,
		},
	)
	if err != nil {
		panic(err)
	}
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:13,代码来源:test.go

示例11: getBucketLocation

func getBucketLocation(c *s3.S3) {
	out, err := c.GetBucketLocation(
		&s3.GetBucketLocationInput{
			Bucket: &bucket,
		},
	)
	if err != nil {
		panic(err)
	}
	if *out.LocationConstraint != "HANGZHOU" {
		panic("location expected HANGZHOU but not")
	}
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:13,代码来源:test.go

示例12: copyObject

func copyObject(c *s3.S3) {
	bucket := "aa-go-sdk"
	source := "aa-go-sdk/aws/config.go"
	key := "test"

	out, _ := c.CopyObject(
		&s3.CopyObjectInput{
			Bucket:     &bucket,
			Key:        &key,
			CopySource: &source,
		},
	)
	fmt.Println(out)
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:14,代码来源:test.go

示例13: multipart

func multipart(c *s3.S3) {
	key := "中文"
	acl := "public-read"
	out, _ := c.CreateMultipartUpload(
		&s3.CreateMultipartUploadInput{
			Bucket: &bucket,
			Key:    &key,
			ACL:    &acl,
		},
	)
	uploadid := out.UploadID

	var partnum int64
	partnum = 1
	s := strings.NewReader("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
	uploadRest, _ := c.UploadPart(
		&s3.UploadPartInput{
			Bucket:     &bucket,
			Key:        &key,
			UploadID:   uploadid,
			PartNumber: &partnum,
			Body:       s,
		},
	)
	fmt.Println(uploadRest)
	listRet, _ := c.ListParts(
		&s3.ListPartsInput{
			Bucket:   &bucket,
			Key:      &key,
			UploadID: uploadid,
		},
	)
	fmt.Println("123")
	listP := listRet.Parts
	for i := 0; i < len(listP); i++ {
		alistP := listP[i]
		fmt.Println(*alistP.PartNumber)
		fmt.Println(*alistP.ETag)
	}
	fmt.Println(*listRet.Key)
	fmt.Println("123")
	var parts []*s3.CompletedPart
	apart := &s3.CompletedPart{
		ETag:       listRet.Parts[0].ETag,
		PartNumber: listRet.Parts[0].PartNumber,
	}
	parts = append(parts, apart)

	comRet, _ := c.CompleteMultipartUpload(
		&s3.CompleteMultipartUploadInput{
			Bucket:   &bucket,
			Key:      &key,
			UploadID: uploadid,
			MultipartUpload: &s3.CompletedMultipartUpload{
				Parts: parts,
			},
		},
	)
	fmt.Println(comRet)
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:60,代码来源:test.go

示例14: listObjects

func listObjects(c *s3.S3) {
	delimiter := "/"
	out, err := c.ListObjects(
		&s3.ListObjectsInput{
			Bucket:    &bucket,
			Delimiter: &delimiter,
		},
	)
	if err != nil {
		panic(err)
	}
	if *out.Delimiter != "/" {
		panic("list objects delimiter expected / but not")
	}
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:15,代码来源:test.go

示例15: putObject

func putObject(c *s3.S3) {
	key := "aws/config.go"
	contenttype := "application/ocet-stream"
	out, err := c.PutObject(
		&s3.PutObjectInput{
			Bucket:      &bucket,
			Key:         &key,
			Body:        strings.NewReader("content"),
			ContentType: &contenttype,
		},
	)
	if err != nil {
		panic(err)
	}
	fmt.Println(out)
}
开发者ID:hadesbox,项目名称:aws-sdk-go,代码行数:16,代码来源:test.go


注:本文中的github.com/ks3sdklib/aws-sdk-go/service/s3.S3类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。