Move Close
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 56s
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 56s
This commit is contained in:
parent
ba717cfdb6
commit
dfd4fc1ecf
38
main.go
38
main.go
@ -108,14 +108,15 @@ func main() {
|
||||
q := req.URL.Query()
|
||||
q.Add("wrap-with-directory", "true")
|
||||
q.Add("progress", "false")
|
||||
q.Add("stream-true", "false")
|
||||
req.URL.RawQuery = q.Encode()
|
||||
|
||||
mwriter := NewIpfsMultipartWriter(writer)
|
||||
req.Header.Add("Content-Type", mwriter.FormDataContentType())
|
||||
|
||||
go func() {
|
||||
defer mwriter.Close()
|
||||
defer writer.Close()
|
||||
defer mwriter.Close()
|
||||
|
||||
err = filepath.Walk(path, func(innerPath string, info fs.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
@ -123,27 +124,24 @@ func main() {
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
// _, 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)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
fileReader, err := os.Open(innerPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fileReader.Close()
|
||||
relPath, _ := filepath.Rel(path, innerPath)
|
||||
w, err := mwriter.CreateIpfsFilePart(url.QueryEscape(fmt.Sprintf("/%v", relPath)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
written, err := io.Copy(w, fileReader)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error copying %s (%d bytes written): %v", innerPath, written, 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
|
||||
|
Loading…
Reference in New Issue
Block a user