Refactor storage methods to remove unused code

This commit is contained in:
Luis Eduardo Jeréz Girón
2024-08-03 22:22:45 -06:00
parent f485d53ce8
commit cceb30b2fb
2 changed files with 4 additions and 35 deletions

View File

@@ -51,15 +51,8 @@ func (Client) LocalDelete(relativeFilePath string) error {
return nil
}
// LocalReadFile Reads a file using the provided path relative to the local
// backups directory.
func (Client) LocalReadFile(relativeFilePath string) (io.ReadCloser, error) {
fullPath := strutil.CreatePath(true, localBackupsDir, relativeFilePath)
file, err := os.Open(fullPath)
if err != nil {
return nil, fmt.Errorf("failed to open file %s: %w", fullPath, err)
}
return file, nil
// LocalGetFullPath Returns the full path of a file using the provided relative
// file path to the local backups directory.
func (Client) LocalGetFullPath(relativeFilePath string) string {
return strutil.CreatePath(true, localBackupsDir, relativeFilePath)
}

View File

@@ -129,27 +129,3 @@ func (Client) S3GetDownloadLink(
return url, nil
}
// S3ReadFile reads a file from S3
func (Client) S3ReadFile(
accessKey, secretKey, region, endpoint, bucketName, key string,
) (io.ReadCloser, error) {
s3Client, err := createS3Client(
accessKey, secretKey, region, endpoint,
)
if err != nil {
return nil, err
}
key = strutil.RemoveLeadingSlash(key)
resp, err := s3Client.GetObject(&s3.GetObjectInput{
Bucket: aws.String(bucketName),
Key: aws.String(key),
})
if err != nil {
return nil, fmt.Errorf("failed to read file from S3: %w", err)
}
return resp.Body, nil
}