Move Close
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 56s

This commit is contained in:
Alexandre Bruyant 2024-01-07 22:19:37 +01:00
parent ba717cfdb6
commit dfd4fc1ecf

12
main.go
View File

@ -108,14 +108,15 @@ func main() {
q := req.URL.Query() q := req.URL.Query()
q.Add("wrap-with-directory", "true") q.Add("wrap-with-directory", "true")
q.Add("progress", "false") q.Add("progress", "false")
q.Add("stream-true", "false")
req.URL.RawQuery = q.Encode() req.URL.RawQuery = q.Encode()
mwriter := NewIpfsMultipartWriter(writer) mwriter := NewIpfsMultipartWriter(writer)
req.Header.Add("Content-Type", mwriter.FormDataContentType()) req.Header.Add("Content-Type", mwriter.FormDataContentType())
go func() { go func() {
defer mwriter.Close()
defer writer.Close() defer writer.Close()
defer mwriter.Close()
err = filepath.Walk(path, func(innerPath string, info fs.FileInfo, err error) error { err = filepath.Walk(path, func(innerPath string, info fs.FileInfo, err error) error {
if err != nil { if err != nil {
@ -123,11 +124,9 @@ func main() {
} }
if info.IsDir() { if info.IsDir() {
// _, err = mwriter.CreateIpfsDirectoryPart(innerPath) return nil
// if err != nil { }
// return err
// }
} else {
relPath, _ := filepath.Rel(path, innerPath) relPath, _ := filepath.Rel(path, innerPath)
w, err := mwriter.CreateIpfsFilePart(url.QueryEscape(fmt.Sprintf("/%v", relPath))) w, err := mwriter.CreateIpfsFilePart(url.QueryEscape(fmt.Sprintf("/%v", relPath)))
if err != nil { if err != nil {
@ -144,7 +143,6 @@ func main() {
if err != nil { if err != nil {
return fmt.Errorf("error copying %s (%d bytes written): %v", innerPath, written, err) return fmt.Errorf("error copying %s (%d bytes written): %v", innerPath, written, err)
} }
}
return nil return nil
}) })