mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-01-23 21:19:31 -06:00
Refactor storage methods to remove unused code
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user