# Download link via http/https

**URL:** <https://discuss.ipfs.tech/t/download-link-via-http-https/8113>\
**Category:** Help\
**Created:** [June 1, 2020, 8:44am UTC](https://discuss.ipfs.tech/t/download-link-via-http-https/8113 "2020-06-01T08:44:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![crashbdx](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/crashbdx/32/3558_2.png) [@crashbdx](https://discuss.ipfs.tech/u/crashbdx)\
**Post date:** [June 1, 2020, 8:44am UTC](https://discuss.ipfs.tech/t/download-link-via-http-https/8113/1 "2020-06-01T08:44:52Z")

</div>

Hi everyone, i have a question, i use IPFS with js-ipfs in my webapp, to add file to infura.

After that i put a link in my webapp using the hash like this:

[https://ipfs.infura.io/hash](https://ipfs.infura.io/hash)

It work well for let’s say images, pdf or so but if the file is something that cannot be read from the browser, like a psd for example, it open the download window and i seem to download the hash, not the file.

I guess this is not the proper way to download a file? or it is not possible via https link ?

Thank you in advance

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [June 2, 2020, 7:27am UTC](https://discuss.ipfs.tech/t/download-link-via-http-https/8113/2 "2020-06-02T07:27:36Z")

</div>

You are probably downloading the file which is renamed to the hash because that’s all that is known about it. If you wrap it in a folder (there’s an option for that), you should be able to keep the filename and reference it like `<hash>/filename` and the download will keep the filename.

---

<div class="post-metadata">

**Author:** ![crashbdx](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/crashbdx/32/3558_2.png) [@crashbdx](https://discuss.ipfs.tech/u/crashbdx)\
**Post date:** [June 2, 2020, 9:56am UTC](https://discuss.ipfs.tech/t/download-link-via-http-https/8113/3 "2020-06-02T09:56:28Z")

</div>

Thank you for your reply i will check that.

---

<div class="post-metadata">

**Author:** ![crashbdx](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/crashbdx/32/3558_2.png) [@crashbdx](https://discuss.ipfs.tech/u/crashbdx)\
**Post date:** [August 15, 2020, 10:28am UTC](https://discuss.ipfs.tech/t/download-link-via-http-https/8113/4 "2020-08-15T10:28:25Z")

</div>

Hello,

I might be missing something but trying to add file keeping file name i do the following:

```
const files = [{ path: "/"+file.name, content: file }];
ipfs.add(files, { pin: true })

```

then i get this result in console when done:

![ipfs](https://us1.discourse-cdn.com/flex020/uploads/ipfs1/original/2X/3/317b4d5cfdc36de7f10923f0a310c0290f9ee47c.jpeg)

Seem that all is good but then i can only access file from cid on gateways, i was expecting cid/path, isn’t it suppose to be like that?

---

<div class="post-metadata">

**Author:** ![ldeffenb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/ldeffenb/32/3996_2.png) [@ldeffenb](https://discuss.ipfs.tech/u/ldeffenb)\
**Post date:** [August 15, 2020, 10:39am UTC](https://discuss.ipfs.tech/t/download-link-via-http-https/8113/5 "2020-08-15T10:39:38Z")

</div>

Just putting the path on the file name doesn’t do it. The add itself must be either the directory path only (in which case I believe all files within the directory tree will be added) or the “wrap-with-directory” flag must be specified as documented at [https://docs.ipfs.io/reference/http/api/#api-v0-add](https://docs.ipfs.io/reference/http/api/#api-v0-add). Otherwise I believe the file will only have a hash to the content and not a hash to a file structure that carries the name for future reference prefixed by the hash.

---

<div class="post-metadata">

**Author:** ![crashbdx](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/crashbdx/32/3558_2.png) [@crashbdx](https://discuss.ipfs.tech/u/crashbdx)\
**Post date:** [August 15, 2020, 10:45am UTC](https://discuss.ipfs.tech/t/download-link-via-http-https/8113/6 "2020-08-15T10:45:19Z")

</div>

Thanks a lot for the replied, i just tried using wrapWithDirectory options as per ipfs-http-client doc: [ipfs.add](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#add)

So my code is now:

```
const files = [{ path: "/"+file.name, content: file }];
ipfs.add(files, { pin: true, wrapWithDirectory: true })

```

But same result so far 😕

---

<div class="post-metadata">

**Author:** ![crashbdx](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/crashbdx/32/3558_2.png) [@crashbdx](https://discuss.ipfs.tech/u/crashbdx)\
**Post date:** [August 15, 2020, 10:50am UTC](https://discuss.ipfs.tech/t/download-link-via-http-https/8113/7 "2020-08-15T10:50:39Z")

</div>

My bad it’s working, thanks a lot 🙂
