New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

file-select

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-select

prompt user for selecting files. +promises, -forms

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
24
-27.27%
Maintainers
1
Weekly downloads
 
Created
Source

file-select

prompt user for selecting files. +promises, -forms

prompt

What is this?

This allows the developer to ask their app/website users for files without creating a form and a file input element.

Installation

npm i --save file-select

Usage

Using a standalone release build

HINT: Check out newest releases here!

<script type="text/javascript" src="/path/to/file-select.min.js"></script>
<script type="text/javascript">

  window.onload = function () {
    fileSelect().then(console.log.bind(console))
  }

</script>

JS ES-stage-0 a.k.a. ES-awesome

import req from 'superagent'
import fileSelect from 'file-select'

async function uploadImages () {
  try {
    const image = await fileSelect({
      maxFileSize: 1024 * 1024 * 10,
      multiple: false,
      accept: 'image/*'
    })

    const res = await req.post('/').attach('image',image)
    alert( 'uploaded' )

  } catch ( err ) {
    alert( 'cancelled' )
  }
}

JS ES5 / CommonJS

var req = require( 'superagent' )
var fileSelect = require( 'file-select' )

function uploadImages () {
  return Promise.try(function () {
    return fileSelect({
      maxFileSize: 1024 * 1024 * 10,
      multiple: false,
      accept: 'image/*'
    })
  })
  .then(function ( images ) {
    return req.post('/').attach('image',image)
  })
  .then(function ( res ) {
    alert( 'uploaded' )
  })
  .catch(function ( err ) {
    alert( 'cancelled' )
  })
}

API

fileSelect

options

Object Object with options.

options.multiple

boolean Allows multiple files selection.

options.maxFileSize

Number Limits select size PER FILE.

options.accept

String | false String with mime types and file extensions separated by commas.

Examples:

  • .jpg,.jpeg
  • image/jpeg,.jpeg,.jpg
  • image/jpeg
  • .pdf
  • .mp3

LICENSE - POL-v1

Private-Open License v1

Keywords

file

FAQs

Package last updated on 02 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts