|
2 | 2 |
|
3 | 3 | File upload library, including: |
4 | 4 |
|
5 | | - - [client side](#client-side) - upload widget + file list viewer ( with pug template ) |
| 5 | + - [client side](#client-side) - upload widget, file list viewer ( with pug template ) and provider adopters. |
6 | 6 | - [server side](#server-side) - API endpoint for file storing with Express |
7 | 7 |
|
8 | 8 |
|
@@ -37,7 +37,9 @@ For more information about provider, check [Provider section](#providers) below. |
37 | 37 |
|
38 | 38 | ### Uploader |
39 | 39 |
|
40 | | -To upload files, create an `uploadr` object through its constructor: |
| 40 | +You can skip Uploadr viewer completely if you only need an API endpoint for each provider. In this case, check [Providers section](#providers) below. |
| 41 | + |
| 42 | +To upload files via uploadr viewer, create an `uploadr` object through its constructor: |
41 | 43 |
|
42 | 44 | var up = new uploadr({ ... }) |
43 | 45 |
|
@@ -85,6 +87,27 @@ To use a provider, you should make sure to |
85 | 87 | - client side: init `uploadr` with proper provider configurations |
86 | 88 | - server side: ensure to add api endpoint if needed. |
87 | 89 |
|
| 90 | +To upload without UI ( Uploadr Viewer ), use client side providers directly which are availables by: |
| 91 | + |
| 92 | + uploadr.ext["<provider-name>"] |
| 93 | + |
| 94 | +Client side providers are function accepting an object with following fields: |
| 95 | + |
| 96 | + - `files`: Array of files to upload. Items for each file are objects with following fields: |
| 97 | + - `thumb`: thumbnail url |
| 98 | + - `file`: corresponding file object |
| 99 | + - `progress(opt)`: progress event handler accepting opt object with following fields: |
| 100 | + - `percent`: progress. 0 ~ 1 |
| 101 | + - `item`: uploading item object with fields described above in `files`. |
| 102 | + - `opt`: corresponding configs described in sections of each provider below. |
| 103 | + |
| 104 | +For example, to upload a file to Google Cloud Storage: |
| 105 | + |
| 106 | + uploader.ext.gcs({ |
| 107 | + files: [{file: new File(["hello"], "hello.txt", {type: "plain/text"})], |
| 108 | + progress: function(opt) { console.log(opt.percent); }, |
| 109 | + opt: {bucket: "my-gcs-bucket"} |
| 110 | + }); |
88 | 111 |
|
89 | 112 | Provider configurations for each provider is described as below. |
90 | 113 |
|
|
0 commit comments