ipfs files write
ipfs files write <path> <data>
命令将数据写入指定的文件。
命令行
ipfs files write [--offset=<offset> | -o] [--create | -e] [--truncate | -t] [--count=<count> | -n] [--] <path> <data>
参数:
<path>
- 要写入的文件路径<data>
- 要写入的数据内容
选项
-o, --offset int - 开始写入的文件内字节偏移量
-e, --create bool - 如果目标文件不存在,是否自动创建
-t, --truncate bool - 是否在写入数据之前将文件清零
-n, --count int - 要写入的最大字节数
说明
ipfs files write
命令将指定的数据写入指定的文件。该命令允许指定数据写入位置。
如果使用了--create
选项,那么当目标文件不存在时将自动创建,但该命令无法自动创建
目标文件路径中不存在的中间路径部分。
如果在执行ipfs files write
命令时设置--flush=false
选项,那么对文件的修改将
不会传播到有向图的根节点,当执行大量写操作或写入深层目录时可以明显提升速度。
示例:
echo "hello world" | ipfs files write --create /myfs/a/b/file
echo "hello world" | ipfs files write --truncate /myfs/a/b/file
警告:
使用--flush=false
选项时,在树刷新之前将无法保证数据一致性。可以在文件或其父
对象上执行ipfs files flush
命令来执行刷新操作。