cleanup
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 34s

This commit is contained in:
matst80
2025-05-16 07:18:32 +02:00
parent ccd4bf56e1
commit d65c9f6998
2 changed files with 3 additions and 10 deletions

View File

@@ -183,7 +183,7 @@ func main() {
if r.Method == "GET" {
content, err := folder.Storage.Get(fileName)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.WriteHeader(http.StatusNotFound)
return
}
w.Header().Set("Content-Type", esimateMimeType(fileName))
@@ -196,6 +196,7 @@ func main() {
authKey := r.Header.Get("Authorization")
if authKey != apiKey {
w.WriteHeader(http.StatusUnauthorized)
log.Printf("auth value %s is not correct, current: %s", authKey, apiKey)
return
}
data, err := io.ReadAll(r.Body)

View File

@@ -40,15 +40,7 @@ func (ds *DiskStorage) Put(key string, data []byte) error {
if err := ds.ensureDir(); err != nil {
return err
}
f, err := os.Open(path.Join(ds.dir, key))
if err != nil {
return err
}
_, err = f.Write(data)
if err != nil {
return err
}
return f.Close()
return os.WriteFile(path.Join(ds.dir, key), data, 0644)
}
func (ds *DiskStorage) Delete(key string) error {