GithubHelp home page GithubHelp logo

alwaysloveme / capacitor-plugin-file-downloader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from veluxa/capacitor-plugin-file-downloader

0.0 2.0 0.0 232 KB

A simple Ionic file downloads native plug-in, which supports Android and ios。一个简单的ionic capacitor 文件下载 native 插件,支持android、ios

Home Page: https://www.npmjs.com/package/capacitor-plugin-file-downloader

Ruby 8.56% Java 50.97% Objective-C 5.70% Swift 22.95% JavaScript 4.64% TypeScript 7.19%

capacitor-plugin-file-downloader's Introduction

capacitor-plugin-file-downloader

file download for capacitor

中文 | English

android ios

一个简单的ionic capacitor 文件下载 native 插件,支持android、ios

安装

npm install capacitor-plugin-file-downloader
ionic capacitor sync

配置

Android配置方法:

在根目录下找到 android 目录 ,依次找到 android/src/main/java/**** (嵌套包名文件夹)/activities/MainActivity.java,修改:

......
import com.veluxa.plugins.FileDownloader;

public class MainActivity extends BridgeActivity {
    ......
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
        ......
        add(FileDownloader.class);
    }});
    ......
}

IOS配置方法: 无需配置

调用

在需要使用到插件的文件,添加:

......
import 'capacitor-plugin-file-downloader';
import { Plugins } from '@capacitor/core';
const { FileDownloader } = Plugins

......

FileDownloader.download({
    url: fileUrl, //下载地址
    filename: filename //包含后缀的文件名
}).then(doc => {
    //下载成功回调
    console.log(doc.path);
}).catch(e => {
    //下载失败回调
})
......

file download for capacitor

A simple ionic capacitor file download native plug-in, support android, ios

Install

npm install capacitor-plugin-file-downloader
ionic capacitor sync

Configuration

Android:

Find the android directory in the root directory, and then find android/src/main/java/**** (nested package name folder)/activities/MainActivity.java, Do the following changes:

......
import com.veluxa.plugins.FileDownloader;

public class MainActivity extends BridgeActivity {
    ......
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
        ......
        add(FileDownloader.class);
    }});
    ......
}

IOS: Don't need to configure

Use

In the files that need to use the plug-in:

......
import 'capacitor-plugin-file-downloader';
import { Plugins } from '@capacitor/core';
const { FileDownloader } = Plugins

......

FileDownloader.download({
    url: fileUrl, //download link
    filename: filename //The file name that contains the suffix
}).then(doc => {
    //success
    console.log(doc.path);
}).catch(e => {
    //error
})
......

capacitor-plugin-file-downloader's People

Contributors

veluxa avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.