Giter Site home page Giter Site logo

apponthebeach / react-native-file-type Goto Github PK

View Code? Open in Web Editor NEW

This project forked from prscx/react-native-file-type

0.0 0.0 0.0 43.07 MB

React Native: Detect the file type of a Buffer/Uint8Array by reading from Local Storage

License: MIT License

JavaScript 24.61% Java 33.13% PostScript 2.33% Objective-C 24.01% Starlark 10.21% Rich Text Format 1.82% Ruby 3.91%

react-native-file-type's Introduction

PRs Welcome

ReactNative - File Type (Android/iOS)

If this project has helped you out, please support us with a star ๐ŸŒŸ

ReactNative: Detect the file type of a Buffer/Uint8Array by reading it from device (Android/iOS/Widnows) file system

This library is a React Native wrapper around sindresorhus/file-type node module.

The file type is detected by checking the magic number of the buffer.

sindresorhus/file-type: fileType(buffer) API, accepts a buffer of binary file data in order to determine it's meta data. Please find below usage for the same:

const readChunk = require('read-chunk');
const fileType = require('file-type');
const buffer = readChunk.sync('unicorn.png', 0, 4100);

fileType(buffer);
//=> {ext: 'png', mime: 'image/png'}

We have created this library for the ease of use. Based on local storage path provided we internally use RNFS to read file and js-base64 to convert data into Uint8Array buffer which is expected by sindresorhus/file-type: fileType(buffer) API

fileType('local-storage-path')

Before we dive into on how to use this library. We would like to thank all the contributor of sindresorhus/file-type for providing such a awesome nice, cool library

Install

npm install react-native-file-type

Internally we are using RNFS to read file. You need to add this library to your project, please follow installation steps RNFS

๐Ÿ’ป Usage

import fileType from 'react-native-file-type'

fileType('local-storage-path').then((type) => {
    //Ext: type.ext
    //MimeType: type.mime
})

โœจ Credits

๐Ÿค” How to contribute

Have an idea? Found a bug? Please raise to ISSUES. Contributions are welcome and are greatly appreciated! Every little bit helps, and credit will always be given.

๐Ÿ’ซ Where is this library used?

If you are using this library in one of your projects, add it in this list below. โœจ

๐Ÿ“œ License

This library is provided under the Apache License.

RNFileType @ prscX

๐Ÿ’– Support my projects

I open-source almost everything I can, and I try to reply everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:

  • Starring and sharing the projects you like ๐Ÿš€

  • If you're feeling especially charitable, please follow prscX on GitHub.

    Buy Me A Coffee

    Thanks! โค๏ธ
    prscX.github.io
    </ Pranav >

react-native-file-type's People

Contributors

prscms avatar prscx avatar joshuapinter avatar mastert 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.