Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for storage class #67

Open
LombardiDaniel opened this issue Dec 11, 2024 · 0 comments
Open

Support for storage class #67

LombardiDaniel opened this issue Dec 11, 2024 · 0 comments

Comments

@LombardiDaniel
Copy link

Support for storage class when creating a backup destination, on the internal/integration/storage/s3.go it would be a simple change:

func (Client) S3Upload(
	accessKey, secretKey, region, endpoint, bucketName, storageClass, key string,
	fileReader io.Reader,
) (int64, error) {
	s3Client, err := createS3Client(
		accessKey, secretKey, region, endpoint,
	)
	if err != nil {
		return 0, err
	}

	key = strutil.RemoveLeadingSlash(key)
	contentType := strutil.GetContentTypeFromFileName(key)

	uploader := s3manager.NewUploaderWithClient(s3Client)
	_, err = uploader.Upload(&s3manager.UploadInput{
		Bucket:       aws.String(bucketName),
		Key:          aws.String(key),
		Body:         fileReader,
		ContentType:  aws.String(contentType),
		StorageClass: aws.String(storageClass),
	})
	if err != nil {
		return 0, fmt.Errorf("failed to upload file to S3: %w", err)
	}

	fileHead, err := s3Client.HeadObject(&s3.HeadObjectInput{
		Bucket: aws.String(bucketName),
		Key:    aws.String(key),
	})
	if err != nil {
		return 0, fmt.Errorf("failed to get uploaded file info from S3: %w", err)
	}
	fileSize := *fileHead.ContentLength

	return fileSize, nil
}

Didn't really look into much more than that though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant