Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rpldy/upload-button

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rpldy/upload-button

Upload button component and asUploadButton HOC

  • 0.1.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.5K
increased by6.21%
Maintainers
1
Weekly downloads
 
Created
Source

Upload Button

Upload button component and asUploadButton HOC

Initiate file upload by opening the browser's native file selection dialog.

Buttons can use different configuration overrides that supersede the options passed to the parent Uploady.

Note: Some options cannot be overriden by the button. For example, any props that influence the file input directly (such as 'multiple')

Installation


   $ yarn add @rpldy/uploady @rpldy/upload-button 

Or


   $ npm i @rpldy/uploady @rpldy/upload-button 

Example

Simple Upload Button

This examples shows how you add Uploady and UploadButton to your app. This is all it takes to get file uploading to work in your React app.


import React from "react";
import Uploady from "@rpldy/uploady";
import UploadButton from "@rpldy/upload-button";

const App = () => (<Uploady
    destination={{ url: "https://my-server/upload" }}>
    <UploadButton/>
</Uploady>);

Custom Upload Button (asUploadButton)

In case you want to use your own component as the upload trigger, use the asUploadButton HOC:


import React from "react";
import Uploady from "@rpldy/uploady";
import { asUploadButton } from "@rpldy/upload-button";

const DivUploadButton = asUploadButton((props) => {
    return <div {...props} style={{ cursor: "pointer" }}>
        DIV Upload Button
    </div>
});

const App = () => (<Uploady
    destination={{ url: "https://my-server/upload" }}>
    <DivUploadButton/>
</Uploady>);

Props

Name (* = mandatory)TypeDefaultDescription
idstringundefinedid attribute to pass to the button element
textstring"Upload"the button text (in case no children passed)
classNamestringundefinedthe class attribute to pass to the button element
childrenReact.Nodeundefinedchild element(s) to render inside the button (replaces text)
extraPropsObjectundefinedany other props to pass to the button component (with spread)
refReact refundefined will be passed to the button element to acquire a ref

In addition, most UploadOptions props can be passed to UploadButton. In order to override configuration passed to the parent Uploady component. See Uploady documentation for detailed list of upload options.

The following guide shows how different upload buttons may use different upload options.

FAQs

Package last updated on 16 Apr 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc