Compare commits
No commits in common. "ba717cfdb69652ec9d222a6abad6a83f171c7d84" and "27894f8ff0dcfc681c45cbe3ef37ca8025f33959" have entirely different histories.
ba717cfdb6
...
27894f8ff0
33
main.go
33
main.go
@ -8,7 +8,6 @@ import (
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/textproto"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -99,15 +98,14 @@ func main() {
|
||||
|
||||
body, writer := io.Pipe()
|
||||
|
||||
targetUrl := fmt.Sprintf("http://%v:%v/api/v0/add", ipfsHost, ipfsPort)
|
||||
req, err := http.NewRequest(http.MethodPost, targetUrl, body)
|
||||
url := fmt.Sprintf("http://%v:%v/api/v0/add", ipfsHost, ipfsPort)
|
||||
req, err := http.NewRequest(http.MethodPost, url, 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)
|
||||
@ -123,13 +121,12 @@ func main() {
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
// _, err = mwriter.CreateIpfsDirectoryPart(innerPath)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
_, err = mwriter.CreateIpfsDirectoryPart(innerPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
relPath, _ := filepath.Rel(path, innerPath)
|
||||
w, err := mwriter.CreateIpfsFilePart(url.QueryEscape(fmt.Sprintf("/%v", relPath)))
|
||||
w, err := mwriter.CreateIpfsFilePart(innerPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -167,15 +164,11 @@ func main() {
|
||||
githubactions.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
githubactions.Infof("Response: %v", string(resBody))
|
||||
d := json.NewDecoder(res.Body)
|
||||
for {
|
||||
var ipfsAddResponse []AddResponse
|
||||
if err := d.Decode(&ipfsAddResponse); err == io.EOF {
|
||||
break
|
||||
} else if err != nil {
|
||||
githubactions.Warningf("Failed to unmarshal response: %v", fmt.Errorf("%w", err))
|
||||
}
|
||||
githubactions.Infof("Received response: %v", ipfsAddResponse)
|
||||
var ipfsAddResponse []AddResponse
|
||||
json.Unmarshal(resBody, &ipfsAddResponse)
|
||||
if err != nil {
|
||||
githubactions.Fatalf(err.Error())
|
||||
}
|
||||
|
||||
githubactions.Infof("Response: %v", ipfsAddResponse)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user