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.

28 lines
542 B

3 years ago
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. bolt "go.etcd.io/bbolt"
  4. )
  5. func AddFileToBucket(bucket *bolt.Bucket, filePath string) error {
  6. var (
  7. fileObject FileObject
  8. fileObjectBytes []byte
  9. err error
  10. )
  11. fileObject, err = CreateFileObject(filePath)
  12. if err != nil {
  13. return nil
  14. }
  15. fileObjectBytes, err = fileObject.ToBytes()
  16. if err != nil {
  17. return err
  18. }
  19. return bucket.Put([]byte(filePath), fileObjectBytes)
  20. }
  21. func RemoveFileFromBucket(bucket *bolt.Bucket, filePath string) error {
  22. return bucket.Delete([]byte(filePath))
  23. }