feat(Config): Added remote target path

This commit is contained in:
netbenix 2021-12-16 18:34:35 +01:00
parent b8e9ddd838
commit cad2dd18d3
5 changed files with 14 additions and 8 deletions

View file

@ -5,8 +5,8 @@ import (
"encoding/json"
"fmt"
"github.com/Azure/azure-storage-file-go/azfile"
"github.com/google/uuid"
"github.com/cheggaaa/pb/v3"
"github.com/google/uuid"
"net/url"
"os"
"path/filepath"
@ -24,7 +24,7 @@ type AzureFileStorage struct{
}
func (azure AzureFileStorage) upload(fileName string, backupName string){
func (azure AzureFileStorage) upload(fileName string, backupName string, destinationPath string){
logger := Logging.DetailedLogger("AzureFileStorage", "upload")
file, err := os.Open(fileName)
@ -43,6 +43,10 @@ func (azure AzureFileStorage) upload(fileName string, backupName string){
logger.Fatal(err)
}
if destinationPath != ""{
azure.TargetDirectory = destinationPath
}
u, _ := url.Parse(fmt.Sprintf("https://%s.file.core.windows.net/%s/%s/%s", azure.StorageAccountName, azure.FileshareName ,azure.TargetDirectory, filepath.Base(fileName)))
fileURL := azfile.NewFileURL(*u, azfile.NewPipeline(credential, azfile.PipelineOptions{}))

View file

@ -3,11 +3,11 @@ package StorageTypes
import "scabiosa/SQL"
type Storage interface {
upload(fileName string, backupName string)
upload(fileName string, backupName string, destinationPath string)
}
func UploadFile(storage Storage, fileName string, backupName string){
storage.upload(fileName, backupName)
func UploadFile(storage Storage, fileName string, backupName string, destinationPath string){
storage.upload(fileName, backupName, destinationPath)
}
func CheckStorageType(storageType string) Storage{