Coder Social home page Coder Social logo

dahjelle / nativescript-share-file Goto Github PK

View Code? Open in Web Editor NEW

This project forked from finanzritter/nativescript-share-file

0.0 2.0 0.0 2.54 MB

Send and share files to other apps in NativeScript using native OS APIs.

License: Apache License 2.0

Shell 12.87% TypeScript 87.13%

nativescript-share-file's Introduction

Nativescript Share File

npm npm Publish

๐Ÿšง Work in progress

This package was forked from the unmaintained package braune-digital/nativescript-share-file. We are currently cleaning up and updating the code.


Send/Share files to other apps.

Android Intent, IOS InteractionController:

.

Installation

Install the plugin in your app.

npm install nativescript-share-file

Usage

Info: Shared files should be in the documents path.

    import { ShareFile } from 'nativescript-share-file';
    import * as fs from 'tns-core-modules/file-system';

    export class TestClass{

        shareFile;
        fileName;
        documents;
        path;
        file;

        constructor() {

            this.fileName = 'text.txt';
            this.documents = fs.knownFolders.documents();
            this.path = fs.path.join(this.documents.path, this.fileName);
            this.file = fs.File.fromPath(this.path);
            this.shareFile = new ShareFile();

            this.shareFile.open( {
                path: this.path,
                intentTitle: 'Open text file with:', // optional Android
                rect: { // optional iPad
                    x: 110,
                    y: 110,
                    width: 0,
                    height: 0
                },
                options: true, // optional iOS
                animated: true // optional iOS
            });
        }
    }

Arguments

path

Path to the file which will be shared.

String: Required

intentTitle

Title for the intent on Android.

String: (Optional) Default: Open file:.

rect

Positioning the view for iPads. On iPhones it's always shown on the bottom.

Object: (Optional) Default: {x: 0, y: 0, width: 0, height: 0 }.

options

Show additional opening options for iOS devices.

Boolean: (Optional) Default: false.

animated

Opening animation for iOS devices.

Boolean: (Optional) Default: false.

Credits

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.