npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-file-delete

v0.1.1

Published

react native package for all mimetype file(html,pdf,image,video,audio,document,etc...) deletion

Downloads

6

Readme

React Native FileDelete

A file-delete for deleting all file types in the ExternalStorageDirectory(Download, Images, Videos, Musique, etc..) of your Android device from react-native. Ex: html, pdf, jpeg, mp3, mp4, docx, etc..

Installation

npm install react-native-file-delete

Or

yarn add react-native-file-delete

Option 1: Automatic

react-native link react-native-file-delete

Option 2: Manual

Android

  • Edit android/settings.gradle to included
include ':react-native-file-delete'
project(':react-native-file-delete').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-file-delete/android')
  • Edit android/app/build.gradle file to include
dependencies {
  ....
  compile project(':react-native-file-delete')
}
  • Edit MainApplication.java to include
// import the package
import com.filedelete.FileDeletePackage;

For Android 10 support you have to place the following line in your AndroidManifest.xml tag android:requestLegacyExternalStorage="true"

<application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/logo"
      android:roundIcon="@mipmap/logo"
      android:allowBackup="false"
      android:theme="@style/AppTheme"
      // ...
      android:requestLegacyExternalStorage="true"> 
// ...
</application>

Usage

FileDelete module provide 03 functions :

  • deleteFile For deleting files by filenames or fileSystemUris you can only use one parameter type. There are 03 ways to initialize your options as shown below.

    import { deleteFile } from 'react-native-file-delete';
    
    // ...
    
    // 1- By Default byNames is false, options contain only External File Uri
    let options = { 
        files: [ 'storage/emulated/0/Download/20180702_121938.pdf', 'storage/emulated/0/Download/10180702_121938.pdf' ]
    };
      
    // 2- byNames is false here, options contain External File Uri and byNames
    let options = { 
        files: [ 'storage/emulated/0/Download/20180702_121938.pdf', 'storage/emulated/0/Download/10180702_121938.pdf' ], 
        byNames: false 
    };
    
    // 3- byNames is true, options contain filenames and byNames
    let options = { 
        files: [ '20180702_121938.pdf', '10180702_121938.pdf' ], 
        byNames: true 
    };
    
    const deletedFileUris = await deleteFile(options);
  • getContentUrisByNames To get the file uri content:// by filename Ex: From 20180702_121938.pdf To content://media/external/file/1000060588

    import { getContentUrisByNames } from 'react-native-file-delete';
    
    // ...
    let options = [ '20180702_121938.pdf', '10180702_121938.pdf' ];
    const uris = await getContentUrisByNames(options); 
  • getContentUrisByFileSystemUris To get the file uri by external file directory uri so function return uri from file:// to content:// Ex: From file://storage/emulated/0/Download/20180702_121938.pdf To content://media/external/file/1000060588

    import { getContentUrisByFileSystemUris } from 'react-native-file-delete';
      
    // ...
    let options = [ 'storage/emulated/0/Download/20180702_121938.pdf', 'storage/emulated/0/Download/10180702_121938.pdf' ];
    const uris = await getContentUrisByFileSystemUris(options);

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library