Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
docs: document --parents flag for files.write command
Browse files Browse the repository at this point in the history
Also adds a test.

Already supported in `js-ipfs`, `go-ipfs` requires ipfs/kubo#5359
to be merged and released
  • Loading branch information
achingbrain committed Aug 9, 2018
1 parent a0559e7 commit 8b91cff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions SPEC/FILES.md
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ Where:
- `offset` is an Integer with the byte offset to begin writing at (default: 0)
- `create` is a Boolean to indicate to create the file if it doesn't exist (default: false)
- `truncate` is a Boolean to indicate if the file should be truncated after writing all the bytes from `content` (default: false)
- `parents` is a Boolean value to decide whether or not to make the parent directories if they don't exist (default: false)
- `length` is an Integer with the maximum number of bytes to read (default: Read all bytes from `content`)
- `raw-leaves`: if true, DAG leaves will contain raw file data and not be wrapped in a protobuf (boolean, default false)
- `cid-version`: the CID version to use when storing the data (storage keys are based on the CID, including it's version) (integer, default 0)
Expand Down
9 changes: 9 additions & 0 deletions js/src/files/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,14 @@ module.exports = (createCommon, options) => {
done()
})
})

it('should write to deeply nested non existent file with create and parents flags, expect no error', function (done) {
const testDir = `/foo/bar/baz/test-${hat()}`

ipfs.files.write(testDir, Buffer.from('Hello, world!'), {create: true, parents: true}, (err) => {
expect(err).to.not.exist()
done()
})
})
})
}

0 comments on commit 8b91cff

Please sign in to comment.