mirror of
https://github.com/studiokaiji/nostr-webhost.git
synced 2025-12-18 23:34:21 +01:00
パスの扱い方を呼び出し元でシンプルになるように変更
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@@ -114,7 +113,7 @@ func uploadMediaFiles(filePaths []string, requests []*http.Request) {
|
||||
|
||||
func filePathToUploadMediaRequest(basePath, filePath, priKey, pubKey string) (*http.Request, error) {
|
||||
// ファイルを開く
|
||||
file, err := os.Open(filepath.Join(basePath, filePath))
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to read %s: %w", filePath, err)
|
||||
}
|
||||
|
||||
@@ -23,13 +23,12 @@ func FindFilesWithBasePathBySuffixes(basePath string, suffixes []string) ([]stri
|
||||
// ファイル名とサフィックスがマッチした場合
|
||||
if strings.HasSuffix(strings.ToLower(info.Name()), strings.ToLower(suffix)) {
|
||||
// フルパスからbasePathまでの相対パスを計算
|
||||
relPath, err := filepath.Rel(basePath, path)
|
||||
if err != nil {
|
||||
fmt.Println("❌ Error calculating relative path:", err)
|
||||
continue
|
||||
}
|
||||
// マッチするファイルの相対パスをスライスに追加
|
||||
filePaths = append(filePaths, "/"+relPath)
|
||||
filePaths = append(filePaths, path)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user