|
@ -8,8 +8,8 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
type IStorageProvider interface { |
|
|
type IStorageProvider interface { |
|
|
storeRaw(bucketName string, objectName string, data []byte) string |
|
|
|
|
|
storeExisting(bucketName string, objectName string, existingFilePath string) string |
|
|
|
|
|
|
|
|
StoreRaw(bucketName string, objectName string, data []byte) string |
|
|
|
|
|
StoreExisting(bucketName string, objectName string, existingFilePath string) string |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type FileSystemStorageProvider struct { |
|
|
type FileSystemStorageProvider struct { |
|
@ -17,7 +17,7 @@ type FileSystemStorageProvider struct { |
|
|
basePath string |
|
|
basePath string |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (sp FileSystemStorageProvider) storeRaw(bucketName string, objectName string, data []byte) string { |
|
|
|
|
|
|
|
|
func (sp FileSystemStorageProvider) StoreRaw(bucketName string, objectName string, data []byte) string { |
|
|
directoryPath := filepath.Join(sp.basePath, bucketName) |
|
|
directoryPath := filepath.Join(sp.basePath, bucketName) |
|
|
|
|
|
|
|
|
sp.fileSystem.MkdirAll(directoryPath, os.ModePerm) |
|
|
sp.fileSystem.MkdirAll(directoryPath, os.ModePerm) |
|
@ -29,8 +29,10 @@ func (sp FileSystemStorageProvider) storeRaw(bucketName string, objectName strin |
|
|
return filePath |
|
|
return filePath |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (sp FileSystemStorageProvider) storeExisting(bucketName string, objectName string, existingFilePath string) string { |
|
|
|
|
|
|
|
|
func (sp FileSystemStorageProvider) StoreExisting(bucketName string, objectName string, existingFilePath string) string { |
|
|
bytesRead, _ := afero.ReadFile(sp.fileSystem, existingFilePath) |
|
|
bytesRead, _ := afero.ReadFile(sp.fileSystem, existingFilePath) |
|
|
|
|
|
|
|
|
return sp.storeRaw(bucketName, objectName, bytesRead) |
|
|
|
|
|
|
|
|
return sp.StoreRaw(bucketName, objectName, bytesRead) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |