ipfs / boxo

A set of reference libraries for building IPFS applications and implementations in Go.
https://github.com/ipfs/boxo#readme
Other
181 stars 82 forks source link

Single file preserve filename in ipfs kubo download in same directory #520

Open ofman opened 7 months ago

ofman commented 7 months ago

If you want to preserve filename in ipfs kubo there is a suggestion in docs and forums to wrap a folder around the file as a workaround but when you want to save a single file in the same directory you get "ErrPathEistsOverwrite" error ("path already exists and overwriting is not allowed") because in github.com/ipfs/boxo@v0.15.0/files/filewriter.go file 38 line there is os.Mkdir(fpath, 0o777) function. Can you fix this either by letting single file case preserve filenames in ipfs or by not calling os.Mkdir if there is only 1 file in directory please? Thanks!

lidel commented 7 months ago

@ofman thank you for reporting, but it is a bit unclear what is the problem. Do you mind providing a code snippet that reproduces the issue?

ofman commented 6 months ago

@ofman thank you for reporting, but it is a bit unclear what is the problem. Do you mind providing a code snippet that reproduces the issue?

@lidel I have created whole new repository just for ya! :) Here it is: https://github.com/ofman/filesharegocli Just go build and do basic usage steps then change shouldWorkButNot := false to shouldWorkButNot := true and you will see the error after go build and basic usage steps.

Basic usage in README.md and below: Use flags -f "example.jpg" or -c "exampleCid" to share files for example: Upload file (keep terminal window open/running to let others download): ./fsg -f go.sum Download file (open new terminal window): ./fsg -c /ipfs/QmX4zdEUtimXgxhpzv8jfFLqkuutNhmoNH987cH5RS67GM

P.S. Also see same issue for other brogrammer here: https://github.com/ipfs/boxo/issues/28