# What does arg "wrap\_with\_directory" from add function do?

**URL:** <https://discuss.ipfs.tech/t/what-does-arg-wrap-with-directory-from-add-function-do/1842>\
**Category:** Help\
**Created:** [January 16, 2018, 7:49am UTC](https://discuss.ipfs.tech/t/what-does-arg-wrap-with-directory-from-add-function-do/1842 "2018-01-16T07:49:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![coolandsmartrr](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/coolandsmartrr/32/619_2.png) [@coolandsmartrr](https://discuss.ipfs.tech/u/coolandsmartrr)\
**Post date:** [January 16, 2018, 7:49am UTC](https://discuss.ipfs.tech/t/what-does-arg-wrap-with-directory-from-add-function-do/1842/1 "2018-01-16T07:49:05Z")

</div>

There’s an argument called `wrap_with_directory` within the `add` function from the ipfsapi ([here in code](https://github.com/ipfs/py-ipfs-api/blob/4be777d940892ffde44f44d6e662764a67e9804d/ipfsapi/client.py#L137)). The description says:

```
wrap_with_directory : bool
            Wrap files with a directory object to preserve their filename
            (Default: ``False``)

```

I’m not exactly sure what this means.  
My guess: Does it place files into a container directory before uploading?  
Whatever the function is, what kind of use cases are there?

---

<div class="post-metadata">

**Author:** ![leerspace](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@leerspace](https://discuss.ipfs.tech/u/leerspace)\
**Post date:** [January 16, 2018, 4:52pm UTC](https://discuss.ipfs.tech/t/what-does-arg-wrap-with-directory-from-add-function-do/1842/2 "2018-01-16T16:52:12Z")

</div>

> [@coolandsmartrr](#):
>
> My guess: Does it place files into a container directory before uploading?

Yes. This is essentially what it does.

> [@coolandsmartrr](#):
>
> Whatever the function is, what kind of use cases are there?

The use case is if you want to preserve the filenames of individual files you’re adding to IPFS that aren’t already in a directory.

---

<div class="post-metadata">

**Author:** ![coolandsmartrr](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/coolandsmartrr/32/619_2.png) [@coolandsmartrr](https://discuss.ipfs.tech/u/coolandsmartrr)\
**Post date:** [January 18, 2018, 4:17am UTC](https://discuss.ipfs.tech/t/what-does-arg-wrap-with-directory-from-add-function-do/1842/3 "2018-01-18T04:17:37Z")

</div>

> [@leerspace](#):
>
> The use case is if you want to preserve the filenames of individual files you’re adding to IPFS that aren’t already in a directory.

As opposed to uploading files directly without wrapping into a folder, because that file would just get addressed by its hash on IPFS?

I’m presuming it goes like this:

```
[->]: Upload onto IPFS

wrap_with_directory: false
  file.txt -> <IPFS hash>
wrap_with_directory: true
  foldername/file.txt -> <IPFS hash>/file.txt

```

---

<div class="post-metadata">

**Author:** ![leerspace](https://avatars.discourse-cdn.com/v4/letter/l/94ad74/32.png) [@leerspace](https://discuss.ipfs.tech/u/leerspace)\
**Post date:** [January 18, 2018, 5:45pm UTC](https://discuss.ipfs.tech/t/what-does-arg-wrap-with-directory-from-add-function-do/1842/4 "2018-01-18T17:45:04Z")

</div>

That’s correct!

\<This post must be at least 20 characters\>
