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"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@@ -114,7 +113,7 @@ func uploadMediaFiles(filePaths []string, requests []*http.Request) {
|
|||||||
|
|
||||||
func filePathToUploadMediaRequest(basePath, filePath, priKey, pubKey string) (*http.Request, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Failed to read %s: %w", filePath, err)
|
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)) {
|
if strings.HasSuffix(strings.ToLower(info.Name()), strings.ToLower(suffix)) {
|
||||||
// フルパスからbasePathまでの相対パスを計算
|
// フルパスからbasePathまでの相対パスを計算
|
||||||
relPath, err := filepath.Rel(basePath, path)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("❌ Error calculating relative path:", err)
|
fmt.Println("❌ Error calculating relative path:", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// マッチするファイルの相対パスをスライスに追加
|
// マッチするファイルの相対パスをスライスに追加
|
||||||
filePaths = append(filePaths, "/"+relPath)
|
filePaths = append(filePaths, path)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user