# react-native-file-delete

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

Latest version **0.1.1** (published 2023-11-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-file-delete
pnpm add react-native-file-delete
yarn add react-native-file-delete
bun add react-native-file-delete
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2023-11-18 |
| First published | 2023-11-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 14.0.0 |
| Dependencies | 0 |
| Unpacked size | 31.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Florent Kemdjeukeng |
| Maintainers | kemflorent |
| Keywords | react-native, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-file-delete
- Repository: https://github.com/kemflorent/react-native-file-delete
- Homepage: https://github.com/kemflorent/react-native-file-delete#readme
- Issues: https://github.com/kemflorent/react-native-file-delete/issues
- npm.io page: https://npm.io/package/react-native-file-delete

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2023-11-18
- 0.1.0 — 2023-11-18

## 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

```sh
npm install react-native-file-delete
```
Or
```sh
yarn add react-native-file-delete
```

### Option 1: Automatic

```sh
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.

    ```js
    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

    ```js
    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

    ```js
    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](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

---

Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)

---
_Source: https://npm.io/package/react-native-file-delete · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
