Example #1
0
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)
}