8.3.0 • Published 3 months ago

pure-upload v8.3.0

Weekly downloads
175
License
MIT
Repository
github
Last release
3 months ago

Pure-upload

npm version Bower version

The pure JS (TS) upload library with no dependencies compatible with Google Chrome, Firefox, IE10+, Edge and modern mobile browsers.

Installation

  1. Download as a ZIP file directly from GitHub pages and include to your project.
  2. Install with npm by npm install pure-upload --save or yarn add pure-upload.
  3. Install with bower by bower install pure-upload.

Example

See a simple example.

Api

Using NPM package:

Import pure-upload with standard import syntax:

import * as pu from "pure-upload";

Uploader

Uploader manages upload queue and registers upload areas.

Initialization:

let uploader = pu.getUploader(uploadQueueOptions, uploadQueueCallbacks);

Upload queue options

maxParallelUploads?: number;
parallelBatchOffset?: number;
autoStart?: boolean;
autoRemove?: boolean;

Upload queue callbacks

onProgressCallback?: (file: IUploadFile) => void;
onCancelledCallback?: (file: IUploadFile) => void;
onFinishedCallback?: (file: IUploadFile) => void;
onUploadedCallback?: (file: IUploadFile) => void;
onErrorCallback?: (file: IUploadFile) => void;
onUploadStartedCallback?: (file: IUploadFile) => void;
onFileAddedCallback?: (file: IUploadFile) => void;
onFileRemovedCallback?: (file: IUploadFile) => void;
onAllFinishedCallback?: () => void;
onQueueChangedCallback?: (queue: IUploadFile[]) => void;
onFilesAddedErrorCallback?: (files: IUploadFile[]) => void;

Upload area

Upload area defines element registered in Uploader.

Registration:

let uploadArea = uploader.registerArea(element, uploadAreaOptions);

Unregistration:

uploader.unregisterArea(uploadArea);

Upload area options

url: string;
method: string;
withCredentials?: boolean;
headers?: { [key: string]: string; };
params?: { [key: string]: string; };
localizer?: ILocalizer;
maxFileSize?: number;
allowDragDrop?: boolean | (() => boolean);
clickable?: boolean | (() => boolean);
accept?: string;
multiple?: boolean;
validateExtension?: boolean;
validateMissingExtension?: boolean;
manualStart?: boolean;
allowEmptyFile?: boolean;
dragOverStyle?: string;
dragOverGlobalStyle?: string;
useCapture?: boolean;
onFileAdded?: (file: IUploadFile) => void;
onFileSelected?: (file: IUploadFile) => void;
onFilesSelected?: (file: IUploadFile[]) => void;
onFileError?: (file: IUploadFile) => void;
onFileCanceled?: (file: IUploadFile) => void;

Upload area - manual starting

start(autoClear?: boolean, files?: IUploadFile[]): void;
clear(files?: IUploadFile[]): void;

Localizer

fileSizeInvalid: (maxFileSize: number) => string;
fileTypeInvalid: (accept: string) => string;
invalidResponseFromServer: () => string;

Upload file

Standard File object extended with additional informations and methods to manage a file in queue.

guid: string;
uploadStatus?: UploadStatus;
responseCode: number;
responseText: string;
progress: number;
sentBytes: number;
errorCode: ErrorCode;
cancel: () => void;
remove: () => void;
start: () => void;

Upload status

File statuses accessible by pu.uploadStatus.

How to develop

Current gulp build tool requires node v16 or v17.

Debug and watch

npm debug-watch

Build and watch example

npm run example-watch

Run example solution

node example

Build package

npm run build

Library used by Quadient.

MIT, Copyright © 2015 Tomáš Růt

8.3.0

3 months ago

8.2.0

3 months ago

8.1.5

1 year ago

8.1.4

2 years ago

8.1.3

2 years ago

8.1.2

2 years ago

8.1.1

2 years ago

8.1.0

3 years ago

8.0.0

3 years ago

7.1.0

3 years ago

7.0.0

3 years ago

6.1.1

3 years ago

6.1.0

3 years ago

6.0.0

4 years ago

5.6.0

4 years ago

5.5.1

4 years ago

5.5.0

4 years ago

5.4.0

4 years ago

5.3.0

5 years ago

5.2.0

5 years ago

5.1.0

5 years ago

5.0.6

5 years ago

5.0.5

6 years ago

5.0.4

6 years ago

5.0.3

6 years ago

5.0.2

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.2.1

7 years ago

4.2.0

7 years ago

4.1.0

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.2.3

7 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.0

7 years ago

2.0.8

7 years ago

2.0.7

7 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

1.0.27

8 years ago

1.0.26

8 years ago

1.0.25

8 years ago

1.0.24

8 years ago

1.0.23

8 years ago

1.0.22

8 years ago

1.0.21

8 years ago

1.0.20

9 years ago

0.0.1

9 years ago

1.0.19

9 years ago

1.0.18

9 years ago

1.0.17

9 years ago

1.0.1

9 years ago

1.0.16

9 years ago

1.0.15

9 years ago

1.0.14

9 years ago

1.0.13

9 years ago

1.0.12

9 years ago

1.0.11

9 years ago

1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.0

9 years ago