Inital commit
This commit is contained in:
commit
df3ec18a6e
11 changed files with 194 additions and 0 deletions
46
StorageTypes/AzureFileStorage.go
Normal file
46
StorageTypes/AzureFileStorage.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package StorageTypes
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"scabiosa/Logging"
|
||||
)
|
||||
|
||||
type AzureFileStorage struct{
|
||||
azcopyPath string
|
||||
storageAccUrl string
|
||||
targetDirectory string
|
||||
SASKey string
|
||||
}
|
||||
|
||||
|
||||
func (azure AzureFileStorage) upload() error{
|
||||
//Do Stuff here
|
||||
return errors.New("lelek")
|
||||
}
|
||||
|
||||
func readConfig() []byte {
|
||||
logger := Logging.DetailedLogger("AzureFileStorage", "readConfig")
|
||||
|
||||
file, err := os.ReadFile("config/azure.json")
|
||||
if err != nil{
|
||||
logger.Fatal(err)
|
||||
}
|
||||
|
||||
return file
|
||||
}
|
||||
|
||||
|
||||
func GetAzureStorage() AzureFileStorage {
|
||||
logger := Logging.DetailedLogger("AzureFileStorage", "GetAzureStorage")
|
||||
|
||||
var azureStorage AzureFileStorage
|
||||
|
||||
jsonErr := json.Unmarshal(readConfig(), &azureStorage)
|
||||
if jsonErr != nil{
|
||||
logger.Fatal(jsonErr)
|
||||
}
|
||||
|
||||
return azureStorage
|
||||
}
|
||||
14
StorageTypes/StorageInterface.go
Normal file
14
StorageTypes/StorageInterface.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package StorageTypes
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Storage interface {
|
||||
upload() error
|
||||
}
|
||||
|
||||
func UploadFile(storage Storage){
|
||||
err := storage.upload()
|
||||
if err != nil{
|
||||
fmt.Print(err)
|
||||
}
|
||||
}
|
||||
Reference in a new issue