PackageManager just because
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
611 B

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. package Filesystem
  2. import (
  3. "fmt"
  4. "os"
  5. bolt "go.etcd.io/bbolt"
  6. )
  7. func AddFileToBucket(bucket *bolt.Bucket, key, filePath string) error {
  8. var (
  9. fileObject FileObject
  10. fileObjectBytes []byte
  11. e error
  12. )
  13. fileObject, e = CreateFileObject(filePath)
  14. if os.IsNotExist(e) {
  15. return nil
  16. }
  17. if e != nil {
  18. return nil
  19. }
  20. fmt.Println(fileObject)
  21. fileObjectBytes, e = fileObject.ToBytes()
  22. if e != nil {
  23. return e
  24. }
  25. return bucket.Put([]byte(key), fileObjectBytes)
  26. }
  27. func RemoveFileFromBucket(bucket *bolt.Bucket, filePath string) error {
  28. return bucket.Delete([]byte(filePath))
  29. }