# \[IONIC 4\] Others methods to download files

**URL:** <https://forum.ionicframework.com/t/ionic-4-others-methods-to-download-files/163042>\
**Category:** Ionic Framework\
**Created:** [May 3, 2019, 9:11pm UTC](https://forum.ionicframework.com/t/ionic-4-others-methods-to-download-files/163042 "2019-05-03T21:11:56Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![adi4208](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@adi4208](https://forum.ionicframework.com/u/adi4208)\
**Post date:** [July 29, 2020, 9:26am UTC](https://forum.ionicframework.com/t/ionic-4-others-methods-to-download-files/163042/21 "2020-07-29T09:26:39Z")

</div>

Hi can you please help me i am using capacitor in my project with ionic 5 and i am getting error code 3 while downloading

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [July 29, 2020, 5:57pm UTC](https://forum.ionicframework.com/t/ionic-4-others-methods-to-download-files/163042/22 "2020-07-29T17:57:27Z")

</div>

The file transfer plugin was sunsetted years ago; just use `HttpClient` to download files.

---

<div class="post-metadata">

**Author:** ![priyansh360](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@priyansh360](https://forum.ionicframework.com/u/priyansh360)\
**Post date:** [June 17, 2021, 5:04am UTC](https://forum.ionicframework.com/t/ionic-4-others-methods-to-download-files/163042/23 "2021-06-17T05:04:17Z")

</div>

Hii @leonardofmed

I am downloading using this code in Android:

```auto
 let uri = encodeURI("https://www.learningcontainer.com/wp-content/uploads/2020/09/Sample-Image-File-for-Testing.png?ezimgfmt=ng:webp/ngcb4");
    const fileTransfer: FileTransferObject = this.transfer.create();
    fileTransfer.download(uri, this.file.dataDirectory + "sample.jpg").then((entry) => {
      console.log(entry);
    })
    .catch((e) =>{
      console.log(e);
    });

```

But i am getting this Error

```auto
FileTransferError

  1. body: null
  2. code: 3
  3. exception: null
  4. http_status: 401
  5. source: "https://www.learningcontainer.com/wp-content/uploads/2020/09/Sample-Image-File-for-Testing.png?ezimgfmt=ng:webp/ngcb4"
  6. target: "file:///data/user/0/com.maximl.demoapp/files/sample.jpg"
  7. __proto__ : Object

```

I have given all the permission’s.  
Same code is working fine in iOS

---

<div class="post-metadata">

**Author:** ![leonardofmed](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@leonardofmed](https://forum.ionicframework.com/u/leonardofmed)\
**Post date:** [June 17, 2021, 10:52am UTC](https://forum.ionicframework.com/t/ionic-4-others-methods-to-download-files/163042/24 "2021-06-17T10:52:55Z")

</div>

You are receiving an error 401 from server, which means you are not authorized to access it. However, as the message before yours says, `FileTransfer` is no longer supported or recommended, the ideal is to replace the method with `HttpClient` from Angular.

> <https://stackoverflow.com/questions/51682514/angular-how-to-download-a-file-from-httpclient/52680514#52680514>

---

<div class="post-metadata">

**Author:** ![priyansh360](https://avatars.discourse-cdn.com/v4/letter/p/ed655f/32.png) [@priyansh360](https://forum.ionicframework.com/u/priyansh360)\
**Post date:** [June 17, 2021, 11:05am UTC](https://forum.ionicframework.com/t/ionic-4-others-methods-to-download-files/163042/25 "2021-06-17T11:05:24Z")

</div>

Hii @leonardofmed ,  
This plugin is not used for Android Downloading.  
But still i can use this plugin for iOS

---

<div class="post-metadata">

**Author:** ![dvtopiya](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@dvtopiya](https://forum.ionicframework.com/u/dvtopiya)\
**Post date:** [November 21, 2021, 8:57am UTC](https://forum.ionicframework.com/t/ionic-4-others-methods-to-download-files/163042/27 "2021-11-21T08:57:03Z")

</div>

Can I download files like pdf,mp3 using URL of the same in Android externalRootDirectory folder using `HttpClient` ?  
Can you please share any example of the same to download it in Android device using url?

---

<div class="post-metadata">

**Author:** ![ryandan29](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@ryandan29](https://forum.ionicframework.com/u/ryandan29)\
**Post date:** [December 28, 2023, 8:54am UTC](https://forum.ionicframework.com/t/ionic-4-others-methods-to-download-files/163042/28 "2023-12-28T08:54:02Z")

</div>

Can you please share any example ?

[Previous page](https://forum.ionicframework.com/t/ionic-4-others-methods-to-download-files/163042.md?page=1)
