diff --git a/main.go b/main.go index 7cfdd41..c1e6915 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "mime/multipart" "net/http" "net/textproto" + "net/url" "os" "path/filepath" "strings" @@ -98,14 +99,15 @@ func main() { body, writer := io.Pipe() - url := fmt.Sprintf("http://%v:%v/api/v0/add", ipfsHost, ipfsPort) - req, err := http.NewRequest(http.MethodPost, url, body) + targetUrl := fmt.Sprintf("http://%v:%v/api/v0/add", ipfsHost, ipfsPort) + req, err := http.NewRequest(http.MethodPost, targetUrl, body) if err != nil { githubactions.Fatalf("Unable to create request: %v", err.Error()) } q := req.URL.Query() q.Add("wrap-with-directory", "true") + q.Add("progress", "false") req.URL.RawQuery = q.Encode() mwriter := NewIpfsMultipartWriter(writer) @@ -121,12 +123,13 @@ func main() { } if info.IsDir() { - _, err = mwriter.CreateIpfsDirectoryPart(innerPath) - if err != nil { - return err - } + // _, err = mwriter.CreateIpfsDirectoryPart(innerPath) + // if err != nil { + // return err + // } } else { - w, err := mwriter.CreateIpfsFilePart(innerPath) + relPath, _ := filepath.Rel(path, innerPath) + w, err := mwriter.CreateIpfsFilePart(url.QueryEscape(fmt.Sprintf("/%v", relPath))) if err != nil { return err } @@ -164,6 +167,7 @@ func main() { githubactions.Fatalf(err.Error()) } + githubactions.Infof("Response: %v", string(resBody)) var ipfsAddResponse []AddResponse json.Unmarshal(resBody, &ipfsAddResponse) if err != nil {