GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - react-component/upload: 📤 Low-level React upload primitive for Ajax, drag, paste, directory, and custom requests.

BranchesTags
Open more actions menu

Latest commit

 

History

455 Commits
455 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.husky
.husky
 
 
docs
docs
 
 
script
script
 
 
src
src
 
 
tests
tests
 
 
.dumirc.ts
.dumirc.ts
 
 
.editorconfig
.editorconfig
 
 
.fatherrc.js
.fatherrc.js
 
 
.fatherrc.ts
.fatherrc.ts
 
 
.gitignore
.gitignore
 
 
.prettierignore
.prettierignore
 
 
.prettierrc
.prettierrc
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
README.zh-CN.md
README.zh-CN.md
 
 
eslint.config.mjs
eslint.config.mjs
 
 
global.d.ts
global.d.ts
 
 
index.js
index.js
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
typings.d.ts
typings.d.ts
 
 
vercel.json
vercel.json
 
 

Repository files navigation

@rc-component/upload

Ant Design Part of the Ant Design ecosystem.

📤 Low-level React upload primitive for Ajax, drag, paste, directory, and custom requests.

NPM version npm downloads build status Codecov bundle size dumi

English | įŽ€äŊ“中文

Highlights

  • Supports Ajax uploads with progress, headers, credentials, and custom request overrides.
  • Supports directory, drag, paste, async action, and before-upload flows.
  • Exposes abort(file) through the component instance for active requests.
  • Provides semantic classNames and styles slots for the hidden input.

Install

npm install @rc-component/upload

Usage

import Upload from '@rc-component/upload';

export default () => (
  <Upload
    action="/upload"
    onStart={file => {
      console.log('start', file.name);
    }}
    onSuccess={(response, file) => {
      console.log('success', file.name, response);
    }}
  >
    <button type="button">Upload</button>
  </Upload>
);

Online preview: https://upload.react-component.vercel.app/

Examples

Run the local dumi site:

npm install
npm start

Then open http://localhost:8000.

API

Upload

Name Type Default Description
accept string | AcceptConfig - Input accept config.
action string | (file) => string | PromiseLike<string> - Upload URL or async resolver.
beforeUpload (file, fileList) => BeforeUploadFileType | Promise<void | BeforeUploadFileType> | void - Validate or transform before upload. Return false to stop upload.
className string - Root class name.
classNames { input?: string } - Semantic class names.
component React.ComponentType | string 'span' Root component.
customRequest CustomUploadRequestOption - Override default request behavior.
data object | (file) => object {} Extra upload data.
directory boolean false Enable directory upload.
disabled boolean false Disable upload trigger.
hasControlInside boolean false Whether child already contains a control element.
headers Record<string, string> {} Request headers.
id string - Input id.
method 'POST' | 'PUT' | 'PATCH' | 'post' | 'put' | 'patch' 'post' Request method.
multiple boolean false Allow multiple file selection.
name string 'file' File field name.
onBatchStart (fileList) => void - Called when a batch starts.
onError (error, response, file) => void - Upload error callback.
onProgress (event, file) => void - Upload progress callback.
onStart (file) => void - Upload start callback.
onSuccess (response, file, xhr) => void - Upload success callback.
openFileDialogOnClick boolean true Open file dialog when root is clicked.
pastable boolean false Enable paste upload.
prefixCls string 'rc-upload' Prefix class name.
style React.CSSProperties - Root style.
styles { input?: React.CSSProperties } - Semantic styles.
withCredentials boolean false Send credentials with Ajax upload.

Methods

Name Type Description
abort (file: RcFile) => void Abort an active upload.
retry (file: RcFile) => void Retry an upload for a specific file.

Development

npm install
npm start
npm test
npm run tsc
npm run compile
npm run build

The dumi site runs at http://localhost:8000 by default.

Release

npm run prepublishOnly

The release flow is handled by @rc-component/np through the rc-np command after the package build.

License

@rc-component/upload is released under the MIT license.

About

📤 Low-level React upload primitive for Ajax, drag, paste, directory, and custom requests.

react-component.github.io/upload

Topics

ant-designantdjavascriptreactreact-component

Resources

Readme
MIT license
Activity
Custom properties

Stars

804 stars

Watchers

31 watching

Forks

323 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.