Browse Source

Add storage provider working directory parameter

feature/update-route-registration
Roman Zipp 3 years ago
committed by Fabian Vowie
parent
commit
fb4cf5b4f4
No known key found for this signature in database GPG Key ID: C27317C33B27C410
  1. 3
      main.go
  2. 6
      storage/storage.go

3
main.go

@ -42,8 +42,7 @@ func RegisterPipelineRoutes(r *mux.Router, pipelines []pipelines.IPipeline, stor
} }
func main() { func main() {
storageProvider := storage.GetFileSystemStorageProvider("test")
storageProvider := storage.GetFileSystemStorageProvider("test", "")
storageProvider.StoreRaw("abc", "def.test", []byte{0x12, 0x10}) storageProvider.StoreRaw("abc", "def.test", []byte{0x12, 0x10})
pipes := pipelines.LoadPipelines() pipes := pipelines.LoadPipelines()

6
storage/storage.go

@ -39,8 +39,10 @@ func (sp FileSystemStorageProvider) StoreExisting(bucketName string, objectName
return sp.StoreRaw(bucketName, objectName, bytesRead) return sp.StoreRaw(bucketName, objectName, bytesRead)
} }
func GetFileSystemStorageProvider(basePath string) FileSystemStorageProvider {
wd, _ := os.Getwd()
func GetFileSystemStorageProvider(basePath string, wd string) FileSystemStorageProvider {
if wd == "" {
wd, _ = os.Getwd()
}
return FileSystemStorageProvider{ return FileSystemStorageProvider{
fileSystem: afero.NewBasePathFs(afero.NewOsFs(), filepath.Join(wd, "files")), fileSystem: afero.NewBasePathFs(afero.NewOsFs(), filepath.Join(wd, "files")),

Loading…
Cancel
Save