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-select-attachment

v0.0.4

Published

Select Cameras, Photos, and Files for react-native applications

Downloads

9

Readme

react-native-select-attachment

Supported Versions

| react-native-select-attachment | react-native | | --- | --- | | >= 0.0.1 | 0.60+

Description

react-native-select-attachment allows the selection of photos, videos, or other files (local or cloud storage like Google Drive, Dropbox, Box). The fileName, fileType, and base64 file data are returned to react-native. This is useful if you want to display or store file data from the device into your application.

Getting Started

$ npm install react-native-select-attachment --save

Android

Not supported in the current release, check back for future releases or create a PR

iOS

CocoaPods on iOS needs this extra step

npx pod-install

To use the react-module, you'll first have to write some privacy descriptions for accessing the photo library and the camera. Open your Info.plist as source and populate the usage descriptions as shown below:

<key>NSMicrophoneUsageDescription</key>
<string>For people to hear you during meetings, we need access to your microphone.</string>
<key>NSCameraUsageDescription</key>
<string>This app wants to take pictures.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app wants to use your photos.</string>

Usage

To import into your react app, import the SelectAttachmentButton component.

import SelectAttachment from 'react-native-select-attachment';

And call showPicker as shown below:

var options = {
    maxFileSize: 10,
    fileTypes: ['png', 'jpg', 'pdf'],
    disableCameraPhotos: false,
    disableCameraVideos: false,
    disablePhotos: false,
    disableVideos: false,
    disableFiles: false,
    cameraLabel: 'Camera',
    albumLabel: 'Album',
    filesLabel: 'Files',
    enableImageScaling : true,
    imageScale : 0.90,
    maxImageWidth : 950
};

SelectAttachment.showPicker(options, (res) => {
    if(res.error){
        console.error(res.error);
    } else {
        console.error(res.fileName);
        console.error(res.fileType);
        console.error(res.base64);
    }
});

Reference

Options

maxFileSize

The max file size allowed of the selected file (in MB)

| Type | Required | Default | | -------- | -------- | ----- | | [String] | No | null |


fileTypes

The file types that will be allowed for selection (in Files). If left blank all file types are allowed for selection

Supported options are:

  • png
  • pdf
  • jpg
  • csv

| Type | Required | Default | | -------- | -------- | ----- | | [String] | No | ['all'] |


disablePhotos

Disables the Camera from the popup options

| Type | Required | Default | | -------- | -------- | -------- | | Boolean | No | false |


disableFiles

Disables the Files from the popup options

| Type | Required | Default | | -------- | -------- | -------- | | Boolean | No | false |


cameraLabel

Overrides the label for Camera popup

| Type | Required | Default | | -------- | -------- | -------- | | String | No | 'Camera' |


albumLabel

Overrides the label for Album popup

| Type | Required | Default | | -------- | -------- | -------- | | String | No | 'Album' |


filesLabel

Overrides the label for Files popup

| Type | Required | Default | | -------- | -------- | -------- | | String | No | 'Files' |


enableImageScaling

Allows scaling images to reduce file size.

| Type | Required | Default | | -------- | -------- | -------- | | Boolean | No | false |


imageScale

If enableImageScaling is true, the image resolution is reduced by a percentage entered. Example 0.5 would reduce the resolution by 50%

| Type | Required | Default | | -------- | -------- | -------- | | Decimal | No | 1.0 |


maxImageWidth

The max width of the image in pixels. Images will be scaled to the entered value. This is useful to reduce file size.

| Type | Required | Default | | -------- | -------- | -------- | | Integer | No | 950 |