Browse Source

Add storage provider working directory parameter

feature/add-image-processing
Roman Zipp 3 years ago
parent
commit
3821f5c7fe
  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