Skip to main content

@rpldy/upload-button

Installation

npm install @rpldy/upload-button

Details

Upload button component and asUploadButton HOC

The UploadButton component renders a simple (un-styled) button that initiates 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.

info

Some options cannot be overridden by the button. For example, any prop that influences the file input directly (such as 'multiple')

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>);
note

asUploadButton makes it possible to gain access to the underlying component with a ref. To support this, it passes along a ref to the component you provide it. For functional components, you'd need to wrap your component with React.forwardRef.

Exports