# Issue: "ipfs add" and "ipfs files write" the difference between the two?

**URL:** <https://discuss.ipfs.tech/t/issue-ipfs-add-and-ipfs-files-write-the-difference-between-the-two/5147>\
**Category:** Kubo\
**Created:** [April 2, 2019, 12:44pm UTC](https://discuss.ipfs.tech/t/issue-ipfs-add-and-ipfs-files-write-the-difference-between-the-two/5147 "2019-04-02T12:44:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VKingi](https://avatars.discourse-cdn.com/v4/letter/v/e79b87/32.png) [@VKingi](https://discuss.ipfs.tech/u/VKingi)\
**Post date:** [April 2, 2019, 12:44pm UTC](https://discuss.ipfs.tech/t/issue-ipfs-add-and-ipfs-files-write-the-difference-between-the-two/5147/1 "2019-04-02T12:44:02Z")

</div>

1. When I use commands:

```sh
 ipfs add test.mp4

```

hash value: QmS2sz7WNaVMDbbuBdzLVNVXwtWsNyNs3S4KjFaYY87aAV

1. When I use commands:

```sh
cat test.mp4 | ipfs files write --create /test/test.mp4

```

hash value: QmazXU4S74VbLjqLouNMuJhKnWp5XKnyp7qqLnRmD3WLgu

> Obviously the two hash values are different,But when I used “ipfs get $hashValue” to download the files, I found they were identical

My question:

1. Why are they different?
2. Why are there two ways to add files, and the difference between them?

All these problems have been bothering me, but I still haven’t found the result. Please help me, thanks.

_mod edit: I’ve imported the text of this post from ["ipfs add" and "ipfs files write" the difference between the two · Issue #6159 · ipfs/kubo · GitHub](https://github.com/ipfs/go-ipfs/issues/6159) for convenience._

---

<div class="post-metadata">

**Author:** ![stebalien](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/stebalien/32/156_2.png) [@stebalien](https://discuss.ipfs.tech/u/stebalien)\
**Post date:** [April 3, 2019, 12:43pm UTC](https://discuss.ipfs.tech/t/issue-ipfs-add-and-ipfs-files-write-the-difference-between-the-two/5147/2 "2019-04-03T12:43:06Z")

</div>

> Why are they different?

When importing files, IPFS chunks the files into small pieces and then builds a merkletree on top of these chunks. By default, `ipfs add ...` generates a _balanced_ merkletree while `ipfs files write` uses a merkletree optimized for appending (IIRC).

> Why are there two ways to add files, and the difference between them?

There are two commands because:

- `ipfs add` just adds the file to IPFS but doesn’t give it a name.
- `ipfs files write --create` puts the file into a virtual filesystem we call MFS (mutable file system). This is often more convenient for managing files (see: [http://127.0.0.1:5001/webui/#/files/](http://127.0.0.1:5001/webui/#/files/)).

Really, we _should_ eventually combine these commands into a more unified API (ideally, one that uses MFS by default). However, that hasn’t been a priority.

---

<div class="post-metadata">

**Author:** ![VKingi](https://avatars.discourse-cdn.com/v4/letter/v/e79b87/32.png) [@VKingi](https://discuss.ipfs.tech/u/VKingi)\
**Post date:** [April 3, 2019, 2:25pm UTC](https://discuss.ipfs.tech/t/issue-ipfs-add-and-ipfs-files-write-the-difference-between-the-two/5147/3 "2019-04-03T14:25:15Z")

</div>

Thank you for your answer.I think both commands are fine, But if the “ipfs files write” command can be improved to:

> ipfs files add test.mp4 /test/test.mp4  
> And  
> ipfs files add -r ./\* /test/

Instead of adding one file at a time:

> cat test.mp4 | ipfs files write --create /test/test.mp4

Thanks again to IPFS for being the best storage I’ve had so far.

---

<div class="post-metadata">

**Author:** ![stebalien](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/stebalien/32/156_2.png) [@stebalien](https://discuss.ipfs.tech/u/stebalien)\
**Post date:** [April 3, 2019, 5:41pm UTC](https://discuss.ipfs.tech/t/issue-ipfs-add-and-ipfs-files-write-the-difference-between-the-two/5147/4 "2019-04-03T17:41:17Z")

</div>

I agree. Note: You can _currently_ run `ipfs files cp /ipfs/$(ipfs add -Q test.mp4) /test/test.mp4`.
