示例#1
0
func putFile(svc *s3.S3, bucket, object string, reader io.ReadSeeker) error {
	_, err := svc.PutObject(&s3.PutObjectInput{
		Bucket: &bucket,
		Key:    &object,
		Body:   reader,
	})

	return err
}
示例#2
0
func putFile(svc *s3.S3, bucket, object string, reader io.ReadSeeker) error {
	_, err := svc.PutObject(&s3.PutObjectInput{
		Bucket:      &bucket,
		Key:         &object,
		Body:        reader,
		ContentType: aws.String("application/tar"),
	})

	return err
}
示例#3
0
func Do(db *bolt.DB, s3Bucket *s3.S3, bucketname string) error {
	err := db.View(func(tx *bolt.Tx) error {
		var b bytes.Buffer
		buffInMem := bufio.NewWriter(&b)
		_, err := tx.WriteTo(buffInMem)
		backupdate := time.Now()
		params := &s3.PutObjectInput{
			Bucket:               aws.String(bucketname),
			Key:                  aws.String(backupdate.Format("2006_01_02_15-04-05")),
			Body:                 bytes.NewReader(b.Bytes()),
			ACL:                  aws.String("authenticated-read"),
			ServerSideEncryption: aws.String("AES256"),
			Metadata: &map[string]*string{
				"bolt-backup": aws.String(backupdate.Format("2006/01/02/15:04:05")),
			},
		}
		_, err = s3Bucket.PutObject(params)
		return err
	})
	return err
}