當前位置: 首頁>>代碼示例>>Golang>>正文


Golang S3.UploadPart方法代碼示例

本文整理匯總了Golang中github.com/ks3sdklib/aws-sdk-go/service/s3.S3.UploadPart方法的典型用法代碼示例。如果您正苦於以下問題:Golang S3.UploadPart方法的具體用法?Golang S3.UploadPart怎麽用?Golang S3.UploadPart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/ks3sdklib/aws-sdk-go/service/s3.S3的用法示例。


在下文中一共展示了S3.UploadPart方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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


注:本文中的github.com/ks3sdklib/aws-sdk-go/service/s3.S3.UploadPart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。