|
|
- package Filesystem
-
- import (
- "fmt"
- "os"
-
- bolt "go.etcd.io/bbolt"
- )
-
- func AddFileToBucket(bucket *bolt.Bucket, key, filePath string) error {
- var (
- fileObject FileObject
- fileObjectBytes []byte
- e error
- )
- fileObject, e = CreateFileObject(filePath)
- if os.IsNotExist(e) {
- return nil
- }
- if e != nil {
- return nil
- }
-
- fmt.Println(fileObject)
-
- fileObjectBytes, e = fileObject.ToBytes()
- if e != nil {
- return e
- }
-
- return bucket.Put([]byte(key), fileObjectBytes)
- }
-
- func RemoveFileFromBucket(bucket *bolt.Bucket, filePath string) error {
- return bucket.Delete([]byte(filePath))
- }
|