Skip to content

Commit

Permalink
fix: remapping assets
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Nov 8, 2024
1 parent a861ef7 commit 357bc37
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions internal/core/plugin_manager/media_manager/assets_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package media_manager
import (
"crypto/sha256"
"encoding/hex"
"os"
"path"
"path/filepath"

Expand Down Expand Up @@ -38,7 +37,7 @@ func (m *MediaBucket) Upload(name string, file []byte) (string, error) {

// store locally
filePath := path.Join(m.mediaPath, filename)
err := os.WriteFile(filePath, file, 0o644)
err := m.oss.Save(filePath, file)
if err != nil {
return "", err
}
Expand All @@ -55,12 +54,7 @@ func (m *MediaBucket) Get(id string) ([]byte, error) {

// check if id is in storage
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 {
return nil, err
}
Expand All @@ -77,5 +71,5 @@ func (m *MediaBucket) Delete(id string) error {

// delete from storage
filePath := path.Join(m.mediaPath, id)
return os.Remove(filePath)
return m.oss.Delete(filePath)
}

0 comments on commit 357bc37

Please sign in to comment.