Test
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 58s

This commit is contained in:
Alexandre Bruyant 2024-01-07 18:35:47 +01:00
parent 6b4eec8251
commit 925ccc3b9e

61
main.go
View File

@ -4,12 +4,10 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/fs"
"mime/multipart" "mime/multipart"
"net/http" "net/http"
"net/textproto" "net/textproto"
"os" "os"
"path/filepath"
"strings" "strings"
"github.com/sethvargo/go-githubactions" "github.com/sethvargo/go-githubactions"
@ -114,42 +112,51 @@ func main() {
defer mwriter.Close() defer mwriter.Close()
defer writer.Close() defer writer.Close()
w, err := mwriter.CreateIpfsDirectoryPart(path) _, err := mwriter.CreateIpfsDirectoryPart(path)
if err != nil { if err != nil {
githubactions.Fatalf("Unable to create root dir path: %v", fmt.Errorf("%w", err)) githubactions.Fatalf("Unable to create root dir path: %v", fmt.Errorf("%w", err))
} }
err = filepath.Walk(path, func(innerPath string, info fs.FileInfo, err error) error { w, err := mwriter.CreateIpfsFilePart("blog/test.html")
if err != nil { if err != nil {
return err githubactions.Fatalf("Unable to create index file part: %v", fmt.Errorf("%w", err))
} }
if info.IsDir() { fileReader, _ := os.Open("blog/test.html")
return nil
}
w, err = mwriter.CreateIpfsFilePart(innerPath)
if err != nil {
return err
}
fileReader, err := os.Open(innerPath)
if err != nil {
return err
}
defer fileReader.Close() defer fileReader.Close()
io.Copy(w, fileReader)
written, err := io.Copy(w, fileReader) // err = filepath.Walk(path, func(innerPath string, info fs.FileInfo, err error) error {
if err != nil { // if err != nil {
return fmt.Errorf("error copying %s (%d bytes written): %v", innerPath, written, err) // return err
} // }
return nil // if info.IsDir() {
}) // return nil
// }
if err != nil { // w, err = mwriter.CreateIpfsFilePart(innerPath)
githubactions.Fatalf("Unable to create request body: %v", fmt.Errorf("%w", err)) // if err != nil {
} // return err
// }
// fileReader, err := os.Open(innerPath)
// if err != nil {
// return err
// }
// defer fileReader.Close()
// written, err := io.Copy(w, fileReader)
// if err != nil {
// return fmt.Errorf("error copying %s (%d bytes written): %v", innerPath, written, err)
// }
// return nil
// })
// if err != nil {
// githubactions.Fatalf("Unable to create request body: %v", fmt.Errorf("%w", err))
// }
}() }()
githubactions.Infof("Calling node API") githubactions.Infof("Calling node API")