Browse Source

fix: remapping assets

Yeuoly 8 months ago
parent
commit
357bc3783b
1 changed files with 3 additions and 9 deletions
  1. 3 9
      internal/core/plugin_manager/media_manager/assets_bucket.go

+ 3 - 9
internal/core/plugin_manager/media_manager/assets_bucket.go

@@ -3,7 +3,6 @@ package media_manager
 import (
 import (
 	"crypto/sha256"
 	"crypto/sha256"
 	"encoding/hex"
 	"encoding/hex"
-	"os"
 	"path"
 	"path"
 	"path/filepath"
 	"path/filepath"
 
 
@@ -38,7 +37,7 @@ func (m *MediaBucket) Upload(name string, file []byte) (string, error) {
 
 
 	// store locally
 	// store locally
 	filePath := path.Join(m.mediaPath, filename)
 	filePath := path.Join(m.mediaPath, filename)
-	err := os.WriteFile(filePath, file, 0o644)
+	err := m.oss.Save(filePath, file)
 	if err != nil {
 	if err != nil {
 		return "", err
 		return "", err
 	}
 	}
@@ -55,12 +54,7 @@ func (m *MediaBucket) Get(id string) ([]byte, error) {
 
 
 	// check if id is in storage
 	// check if id is in storage
 	filePath := path.Join(m.mediaPath, id)
 	filePath := path.Join(m.mediaPath, id)
-	if _, err := os.Stat(filePath); os.IsNotExist(err) {
-		return nil, err
-	}
-
-	// read file
-	file, err := os.ReadFile(filePath)
+	file, err := m.oss.Load(filePath)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -77,5 +71,5 @@ func (m *MediaBucket) Delete(id string) error {
 
 
 	// delete from storage
 	// delete from storage
 	filePath := path.Join(m.mediaPath, id)
 	filePath := path.Join(m.mediaPath, id)
-	return os.Remove(filePath)
+	return m.oss.Delete(filePath)
 }
 }