@scaleflex/widget-xhr-upload 4.0.7 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7050 -7022
- package/LICENSE +21 -21
- package/README.md +200 -200
- package/lib/index.js +26 -26
- package/package.json +4 -4
- package/types/index.d.ts +22 -22
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 scaleflex
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 scaleflex
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,200 +1,200 @@
|
|
|
1
|
-
# `@scaleflex/widget-xhr-upload`
|
|
2
|
-
|
|
3
|
-
[![Plugins][plugins-image]](#plugins)
|
|
4
|
-
[![Website][filerobot-image]][sfx-url]
|
|
5
|
-
[![Version][filerobot-version]][version-url]
|
|
6
|
-
[![Scaleflex team][made-by-image]][sfx-url]
|
|
7
|
-
[![License][license-image]][license-url]
|
|
8
|
-
[![CodeSandbox][codeSandbox-image]][codeSandbox-url]
|
|
9
|
-
|
|
10
|
-
<div align='center'>
|
|
11
|
-
<img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://assets.scaleflex.com/Corporate+Branding/%5B2025%5D+ALL+LOGOS+%2B+ICONS/SCALEFLEX/VXP+logo/Horizontal+White/VXP+logo+WHITE.png?vh=663932" width="140"/>
|
|
12
|
-
</div>
|
|
13
|
-
|
|
14
|
-
The XHR upload plugin for [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core) handles uploading files in Multipart form uploading way and HTTP(s) protocol.
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
### NPM
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm install --save @scaleflex/widget-xhr-upload
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### YARN
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
yarn add @scaleflex/widget-xhr-upload
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
then
|
|
31
|
-
|
|
32
|
-
```js
|
|
33
|
-
import XHRUpload from '@scaleflex/widget-xhr-upload'
|
|
34
|
-
...
|
|
35
|
-
...
|
|
36
|
-
...
|
|
37
|
-
scaleflexWidget.use(XHRUpload, propertiesObject)
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### CDN
|
|
41
|
-
|
|
42
|
-
The plugin from CDN is found inside `Scaleflex` global object `Scaleflex.XHRUpload`
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
const XHRUpload = window.ScaleflexWidget.XHRUpload
|
|
46
|
-
...
|
|
47
|
-
...
|
|
48
|
-
...
|
|
49
|
-
scaleflexWidget.use(XHRUpload, propertiesObject)
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Example
|
|
53
|
-
|
|
54
|
-
You can use upload in two ways:
|
|
55
|
-
|
|
56
|
-
- By using [Progress Panel](../@scaleflex/widget-progress-panel#Example) plugin, please check the example there.
|
|
57
|
-
- By using widget events, please check how to use events [here](..@scaleflex/widget-core/#upload) and see the example below:
|
|
58
|
-
|
|
59
|
-
```js
|
|
60
|
-
const ScaleflexWidget = window.ScaleflexWidget;
|
|
61
|
-
const demoContainer = "scaleflex-tests-v5a";
|
|
62
|
-
const demoSecurityTemplateId = "......";
|
|
63
|
-
|
|
64
|
-
const scaleflexWidget = ScaleflexWidget.Core({
|
|
65
|
-
securityTemplateId: demoSecurityTemplateId,
|
|
66
|
-
container: demoContainer,
|
|
67
|
-
dev: false, // optional, default: false
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const Explorer = ScaleflexWidget.Explorer;
|
|
71
|
-
const XHRUpload = ScaleflexWidget.XHRUpload;
|
|
72
|
-
|
|
73
|
-
scaleflexWidget
|
|
74
|
-
.use(Explorer, { target: "#scaleflex-widget", inline: true })
|
|
75
|
-
.use(XHRUpload);
|
|
76
|
-
|
|
77
|
-
// events
|
|
78
|
-
scaleflexWidget.on("upload", () => {
|
|
79
|
-
// trigger when upload is clicked inside explorer
|
|
80
|
-
});
|
|
81
|
-
scaleflexWidget.on("upload-started", () => {
|
|
82
|
-
// trigger when upload starts
|
|
83
|
-
});
|
|
84
|
-
scaleflexWidget.on("upload-progress", () => {
|
|
85
|
-
// trigger when upload is progressing
|
|
86
|
-
});
|
|
87
|
-
scaleflexWidget.on("upload-success", () => {
|
|
88
|
-
// trigger when upload is completed
|
|
89
|
-
});
|
|
90
|
-
scaleflexWidget.on("upload-error", () => {
|
|
91
|
-
// trigger when upload has an error
|
|
92
|
-
});
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Properties
|
|
96
|
-
|
|
97
|
-
### `uploadToFolderPath`
|
|
98
|
-
|
|
99
|
-
<u>Type:</u> `string`.
|
|
100
|
-
|
|
101
|
-
<u>Default:</u> `null`
|
|
102
|
-
|
|
103
|
-
The path of the folder that will be used in uploading to, if this property is provided it will override the current opened folder path and files would be uploaded to this path.
|
|
104
|
-
|
|
105
|
-
> Note: you shouldn't provide `folder=...` in the `uploadQueryParams` if you want to use this property or `uploadQueryParams` will override this property's value.
|
|
106
|
-
|
|
107
|
-
### `uploadQueryParams: string`
|
|
108
|
-
|
|
109
|
-
<u>Type:</u> `string`.
|
|
110
|
-
|
|
111
|
-
<u>Default:</u> `''`
|
|
112
|
-
|
|
113
|
-
The query to be appended to the upload url, ex. `../upload?`**`extra=hello&foo=bar`**.
|
|
114
|
-
|
|
115
|
-
### `limit`
|
|
116
|
-
|
|
117
|
-
<u>Type:</u> `number`.
|
|
118
|
-
|
|
119
|
-
<u>Default:</u> `0`
|
|
120
|
-
|
|
121
|
-
Limit the number of uploads' requests handled at the same if left `0` then there is no limit.
|
|
122
|
-
|
|
123
|
-
### `timeout`
|
|
124
|
-
|
|
125
|
-
<u>Type:</u> `number`.
|
|
126
|
-
|
|
127
|
-
<u>Default:</u> `60 * 1000`
|
|
128
|
-
|
|
129
|
-
Defines the timeout for not receiving upload events or having no uploading's progress after that amount of milliseconds it abort the upload assuming there is a problem with the connection, if set to `0` this feature will be disabled.
|
|
130
|
-
|
|
131
|
-
### `headers: `
|
|
132
|
-
|
|
133
|
-
<u>Type:</u> `object`.
|
|
134
|
-
|
|
135
|
-
<u>Default:</u> `{X-Scaleflex-Key: '...'}`
|
|
136
|
-
|
|
137
|
-
If you want to customize the headers of the upload requests are being sent to the backend.
|
|
138
|
-
|
|
139
|
-
### `info`
|
|
140
|
-
|
|
141
|
-
<u>Type:</u> `object`.
|
|
142
|
-
|
|
143
|
-
<u>Default:</u> `undefined`
|
|
144
|
-
|
|
145
|
-
If you want to pass some info to the file pass an object with the needed info to this property and it would be considered while uploading the file, example: `{ recipe_id: 10 }`.
|
|
146
|
-
|
|
147
|
-
> Note: Applied only for local uploads <!-- maybe, because the backend doesn't support all info data fields? -->
|
|
148
|
-
|
|
149
|
-
### `addInfoCallback`
|
|
150
|
-
|
|
151
|
-
<u>Type:</u> `function`.
|
|
152
|
-
|
|
153
|
-
<u>Default:</u> `undefined`
|
|
154
|
-
|
|
155
|
-
If you want to pass some info to the file after doing some operation/functionality, pass a function that has `file` object as a parameter that contains the file's details and returns an object of the info data to be passed and saved to the file while uploading otherwise the function won't be considered.
|
|
156
|
-
|
|
157
|
-
Example, `(file) => (file.name === 'first' ? { file_order: 'first' } : false)`
|
|
158
|
-
|
|
159
|
-
> Note: Applied only for local uploads <!-- maybe, because the backend doesn't support all info data fields? -->
|
|
160
|
-
|
|
161
|
-
### `meta`
|
|
162
|
-
|
|
163
|
-
<u>Type:</u> `object`.
|
|
164
|
-
|
|
165
|
-
_default_: `undefined`
|
|
166
|
-
|
|
167
|
-
Add some meta in the file object by providing the meta as object to this property , example: `{ recipe_category: 'Vegetables' }`.
|
|
168
|
-
|
|
169
|
-
> Note: Applied only for local uploads
|
|
170
|
-
|
|
171
|
-
### `locale`
|
|
172
|
-
|
|
173
|
-
<u>Type:</u> `object`.
|
|
174
|
-
|
|
175
|
-
<u>Default:</u>
|
|
176
|
-
|
|
177
|
-
```js
|
|
178
|
-
{
|
|
179
|
-
strings: {
|
|
180
|
-
timedOut: "Upload stalled for %{seconds} seconds, aborting.";
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
Customizing some of the translations or the language's strings and replace the default locale.
|
|
186
|
-
|
|
187
|
-
<!-- Variables -->
|
|
188
|
-
|
|
189
|
-
[npm-url]: https://www.npmjs.com/package/@scaleflex/widget-xhr-upload
|
|
190
|
-
[license-url]: https://opensource.org/licenses/MIT
|
|
191
|
-
[sfx-url]: https://www.scaleflex.com/
|
|
192
|
-
[version-url]: https://www.npmjs.com/package/@scaleflex/widget-xhr-upload
|
|
193
|
-
[codeSandbox-url]: https://codesandbox.io/p/sandbox/scalelfex-widget-v4-sandbox-dtp6l3?file=%2Fsrc%2Findex.js
|
|
194
|
-
[npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
|
|
195
|
-
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
|
|
196
|
-
[made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
|
|
197
|
-
[plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
|
|
198
|
-
[filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
|
|
199
|
-
[filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-xhr-upload?label=Version&style=for-the-badge&logo=npm
|
|
200
|
-
[codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
|
|
1
|
+
# `@scaleflex/widget-xhr-upload`
|
|
2
|
+
|
|
3
|
+
[![Plugins][plugins-image]](#plugins)
|
|
4
|
+
[![Website][filerobot-image]][sfx-url]
|
|
5
|
+
[![Version][filerobot-version]][version-url]
|
|
6
|
+
[![Scaleflex team][made-by-image]][sfx-url]
|
|
7
|
+
[![License][license-image]][license-url]
|
|
8
|
+
[![CodeSandbox][codeSandbox-image]][codeSandbox-url]
|
|
9
|
+
|
|
10
|
+
<div align='center'>
|
|
11
|
+
<img title="Scaleflex Widget logo" alt="Scaleflex Widget logo" src="https://assets.scaleflex.com/Corporate+Branding/%5B2025%5D+ALL+LOGOS+%2B+ICONS/SCALEFLEX/VXP+logo/Horizontal+White/VXP+logo+WHITE.png?vh=663932" width="140"/>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
The XHR upload plugin for [Scaleflex Media Asset Widget](https://www.npmjs.com/package/@scaleflex/widget-core) handles uploading files in Multipart form uploading way and HTTP(s) protocol.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### NPM
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install --save @scaleflex/widget-xhr-upload
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### YARN
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
yarn add @scaleflex/widget-xhr-upload
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
then
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import XHRUpload from '@scaleflex/widget-xhr-upload'
|
|
34
|
+
...
|
|
35
|
+
...
|
|
36
|
+
...
|
|
37
|
+
scaleflexWidget.use(XHRUpload, propertiesObject)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### CDN
|
|
41
|
+
|
|
42
|
+
The plugin from CDN is found inside `Scaleflex` global object `Scaleflex.XHRUpload`
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
const XHRUpload = window.ScaleflexWidget.XHRUpload
|
|
46
|
+
...
|
|
47
|
+
...
|
|
48
|
+
...
|
|
49
|
+
scaleflexWidget.use(XHRUpload, propertiesObject)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Example
|
|
53
|
+
|
|
54
|
+
You can use upload in two ways:
|
|
55
|
+
|
|
56
|
+
- By using [Progress Panel](../@scaleflex/widget-progress-panel#Example) plugin, please check the example there.
|
|
57
|
+
- By using widget events, please check how to use events [here](..@scaleflex/widget-core/#upload) and see the example below:
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
const ScaleflexWidget = window.ScaleflexWidget;
|
|
61
|
+
const demoContainer = "scaleflex-tests-v5a";
|
|
62
|
+
const demoSecurityTemplateId = "......";
|
|
63
|
+
|
|
64
|
+
const scaleflexWidget = ScaleflexWidget.Core({
|
|
65
|
+
securityTemplateId: demoSecurityTemplateId,
|
|
66
|
+
container: demoContainer,
|
|
67
|
+
dev: false, // optional, default: false
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const Explorer = ScaleflexWidget.Explorer;
|
|
71
|
+
const XHRUpload = ScaleflexWidget.XHRUpload;
|
|
72
|
+
|
|
73
|
+
scaleflexWidget
|
|
74
|
+
.use(Explorer, { target: "#scaleflex-widget", inline: true })
|
|
75
|
+
.use(XHRUpload);
|
|
76
|
+
|
|
77
|
+
// events
|
|
78
|
+
scaleflexWidget.on("upload", () => {
|
|
79
|
+
// trigger when upload is clicked inside explorer
|
|
80
|
+
});
|
|
81
|
+
scaleflexWidget.on("upload-started", () => {
|
|
82
|
+
// trigger when upload starts
|
|
83
|
+
});
|
|
84
|
+
scaleflexWidget.on("upload-progress", () => {
|
|
85
|
+
// trigger when upload is progressing
|
|
86
|
+
});
|
|
87
|
+
scaleflexWidget.on("upload-success", () => {
|
|
88
|
+
// trigger when upload is completed
|
|
89
|
+
});
|
|
90
|
+
scaleflexWidget.on("upload-error", () => {
|
|
91
|
+
// trigger when upload has an error
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Properties
|
|
96
|
+
|
|
97
|
+
### `uploadToFolderPath`
|
|
98
|
+
|
|
99
|
+
<u>Type:</u> `string`.
|
|
100
|
+
|
|
101
|
+
<u>Default:</u> `null`
|
|
102
|
+
|
|
103
|
+
The path of the folder that will be used in uploading to, if this property is provided it will override the current opened folder path and files would be uploaded to this path.
|
|
104
|
+
|
|
105
|
+
> Note: you shouldn't provide `folder=...` in the `uploadQueryParams` if you want to use this property or `uploadQueryParams` will override this property's value.
|
|
106
|
+
|
|
107
|
+
### `uploadQueryParams: string`
|
|
108
|
+
|
|
109
|
+
<u>Type:</u> `string`.
|
|
110
|
+
|
|
111
|
+
<u>Default:</u> `''`
|
|
112
|
+
|
|
113
|
+
The query to be appended to the upload url, ex. `../upload?`**`extra=hello&foo=bar`**.
|
|
114
|
+
|
|
115
|
+
### `limit`
|
|
116
|
+
|
|
117
|
+
<u>Type:</u> `number`.
|
|
118
|
+
|
|
119
|
+
<u>Default:</u> `0`
|
|
120
|
+
|
|
121
|
+
Limit the number of uploads' requests handled at the same if left `0` then there is no limit.
|
|
122
|
+
|
|
123
|
+
### `timeout`
|
|
124
|
+
|
|
125
|
+
<u>Type:</u> `number`.
|
|
126
|
+
|
|
127
|
+
<u>Default:</u> `60 * 1000`
|
|
128
|
+
|
|
129
|
+
Defines the timeout for not receiving upload events or having no uploading's progress after that amount of milliseconds it abort the upload assuming there is a problem with the connection, if set to `0` this feature will be disabled.
|
|
130
|
+
|
|
131
|
+
### `headers: `
|
|
132
|
+
|
|
133
|
+
<u>Type:</u> `object`.
|
|
134
|
+
|
|
135
|
+
<u>Default:</u> `{X-Scaleflex-Key: '...'}`
|
|
136
|
+
|
|
137
|
+
If you want to customize the headers of the upload requests are being sent to the backend.
|
|
138
|
+
|
|
139
|
+
### `info`
|
|
140
|
+
|
|
141
|
+
<u>Type:</u> `object`.
|
|
142
|
+
|
|
143
|
+
<u>Default:</u> `undefined`
|
|
144
|
+
|
|
145
|
+
If you want to pass some info to the file pass an object with the needed info to this property and it would be considered while uploading the file, example: `{ recipe_id: 10 }`.
|
|
146
|
+
|
|
147
|
+
> Note: Applied only for local uploads <!-- maybe, because the backend doesn't support all info data fields? -->
|
|
148
|
+
|
|
149
|
+
### `addInfoCallback`
|
|
150
|
+
|
|
151
|
+
<u>Type:</u> `function`.
|
|
152
|
+
|
|
153
|
+
<u>Default:</u> `undefined`
|
|
154
|
+
|
|
155
|
+
If you want to pass some info to the file after doing some operation/functionality, pass a function that has `file` object as a parameter that contains the file's details and returns an object of the info data to be passed and saved to the file while uploading otherwise the function won't be considered.
|
|
156
|
+
|
|
157
|
+
Example, `(file) => (file.name === 'first' ? { file_order: 'first' } : false)`
|
|
158
|
+
|
|
159
|
+
> Note: Applied only for local uploads <!-- maybe, because the backend doesn't support all info data fields? -->
|
|
160
|
+
|
|
161
|
+
### `meta`
|
|
162
|
+
|
|
163
|
+
<u>Type:</u> `object`.
|
|
164
|
+
|
|
165
|
+
_default_: `undefined`
|
|
166
|
+
|
|
167
|
+
Add some meta in the file object by providing the meta as object to this property , example: `{ recipe_category: 'Vegetables' }`.
|
|
168
|
+
|
|
169
|
+
> Note: Applied only for local uploads
|
|
170
|
+
|
|
171
|
+
### `locale`
|
|
172
|
+
|
|
173
|
+
<u>Type:</u> `object`.
|
|
174
|
+
|
|
175
|
+
<u>Default:</u>
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
{
|
|
179
|
+
strings: {
|
|
180
|
+
timedOut: "Upload stalled for %{seconds} seconds, aborting.";
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Customizing some of the translations or the language's strings and replace the default locale.
|
|
186
|
+
|
|
187
|
+
<!-- Variables -->
|
|
188
|
+
|
|
189
|
+
[npm-url]: https://www.npmjs.com/package/@scaleflex/widget-xhr-upload
|
|
190
|
+
[license-url]: https://opensource.org/licenses/MIT
|
|
191
|
+
[sfx-url]: https://www.scaleflex.com/
|
|
192
|
+
[version-url]: https://www.npmjs.com/package/@scaleflex/widget-xhr-upload
|
|
193
|
+
[codeSandbox-url]: https://codesandbox.io/p/sandbox/scalelfex-widget-v4-sandbox-dtp6l3?file=%2Fsrc%2Findex.js
|
|
194
|
+
[npm-image]: https://img.shields.io/npm/v/@telus/remark-config.svg?style=for-the-badge&logo=npm
|
|
195
|
+
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge
|
|
196
|
+
[made-by-image]: https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg?style=for-the-badge
|
|
197
|
+
[plugins-image]: https://img.shields.io/static/v1?label=Scaleflex&message=Plugins&color=yellow&style=for-the-badge
|
|
198
|
+
[filerobot-image]: https://img.shields.io/static/v1?label=Scaleflex&message=website&color=orange&style=for-the-badge
|
|
199
|
+
[filerobot-version]: https://img.shields.io/npm/v/@scaleflex/widget-xhr-upload?label=Version&style=for-the-badge&logo=npm
|
|
200
|
+
[codeSandbox-image]: https://img.shields.io/badge/CodeSandbox-black?style=for-the-badge&logo=CodeSandbox
|
package/lib/index.js
CHANGED
|
@@ -73,13 +73,13 @@ function buildResponseError(xhr, error) {
|
|
|
73
73
|
return error;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
/**
|
|
77
|
-
* Set `data.type` in the blob to `file.info.type`,
|
|
78
|
-
* because we might have detected a more accurate file type in Filerobot
|
|
79
|
-
* https://stackoverflow.com/a/50875615
|
|
80
|
-
*
|
|
81
|
-
* @param {object} file File object with `data`, `size` and `info` properties
|
|
82
|
-
* @returns {object} blob updated with the new `type` set from `file.info.type`
|
|
76
|
+
/**
|
|
77
|
+
* Set `data.type` in the blob to `file.info.type`,
|
|
78
|
+
* because we might have detected a more accurate file type in Filerobot
|
|
79
|
+
* https://stackoverflow.com/a/50875615
|
|
80
|
+
*
|
|
81
|
+
* @param {object} file File object with `data`, `size` and `info` properties
|
|
82
|
+
* @returns {object} blob updated with the new `type` set from `file.info.type`
|
|
83
83
|
*/
|
|
84
84
|
function setTypeInBlob(file) {
|
|
85
85
|
var dataWithUpdatedType = file.data.slice(0, file.data.size, file.info.type);
|
|
@@ -119,15 +119,15 @@ var XHRUpload = /*#__PURE__*/function (_Plugin) {
|
|
|
119
119
|
addInfoCallback: undefined,
|
|
120
120
|
meta: undefined,
|
|
121
121
|
skipUpload: false,
|
|
122
|
-
/**
|
|
123
|
-
* @typedef respObj
|
|
124
|
-
* @property {string} responseText
|
|
125
|
-
* @property {number} status
|
|
126
|
-
* @property {string} statusText
|
|
127
|
-
* @property {object.<string, string>} headers
|
|
128
|
-
*
|
|
129
|
-
* @param {string} responseText the response body string
|
|
130
|
-
* @param {XMLHttpRequest | respObj} response the response object (XHR or similar)
|
|
122
|
+
/**
|
|
123
|
+
* @typedef respObj
|
|
124
|
+
* @property {string} responseText
|
|
125
|
+
* @property {number} status
|
|
126
|
+
* @property {string} statusText
|
|
127
|
+
* @property {object.<string, string>} headers
|
|
128
|
+
*
|
|
129
|
+
* @param {string} responseText the response body string
|
|
130
|
+
* @param {XMLHttpRequest | respObj} response the response object (XHR or similar)
|
|
131
131
|
*/
|
|
132
132
|
getResponseData: function getResponseData(responseText, response) {
|
|
133
133
|
var parsedResponse = {};
|
|
@@ -138,10 +138,10 @@ var XHRUpload = /*#__PURE__*/function (_Plugin) {
|
|
|
138
138
|
}
|
|
139
139
|
return parsedResponse;
|
|
140
140
|
},
|
|
141
|
-
/**
|
|
142
|
-
*
|
|
143
|
-
* @param {string} responseText the response body string
|
|
144
|
-
* @param {XMLHttpRequest | respObj} response the response object (XHR or similar)
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
* @param {string} responseText the response body string
|
|
144
|
+
* @param {XMLHttpRequest | respObj} response the response object (XHR or similar)
|
|
145
145
|
*/
|
|
146
146
|
getResponseError: function getResponseError(responseText, response) {
|
|
147
147
|
var error = new Error('Upload error');
|
|
@@ -156,12 +156,12 @@ var XHRUpload = /*#__PURE__*/function (_Plugin) {
|
|
|
156
156
|
}
|
|
157
157
|
return error;
|
|
158
158
|
},
|
|
159
|
-
/**
|
|
160
|
-
* Check if the response from the upload endpoint indicates that the upload was successful.
|
|
161
|
-
*
|
|
162
|
-
* @param {number} status the response status code
|
|
163
|
-
* @param {string} responseText the response body string
|
|
164
|
-
* @param {XMLHttpRequest | respObj} response the response object (XHR or similar)
|
|
159
|
+
/**
|
|
160
|
+
* Check if the response from the upload endpoint indicates that the upload was successful.
|
|
161
|
+
*
|
|
162
|
+
* @param {number} status the response status code
|
|
163
|
+
* @param {string} responseText the response body string
|
|
164
|
+
* @param {XMLHttpRequest | respObj} response the response object (XHR or similar)
|
|
165
165
|
*/
|
|
166
166
|
validateStatus: function validateStatus(status, responseText, response) {
|
|
167
167
|
return status >= 200 && status < 300;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/widget-xhr-upload",
|
|
3
3
|
"description": "Plain and simple classic HTML multipart form uploads with Scaleflex Media Asset Widget, as well as uploads using the HTTP PUT method.",
|
|
4
|
-
"version": "4.0
|
|
4
|
+
"version": "4.3.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@scaleflex/widget-companion-client": "^4.0
|
|
18
|
-
"@scaleflex/widget-utils": "^4.0
|
|
17
|
+
"@scaleflex/widget-companion-client": "^4.3.0",
|
|
18
|
+
"@scaleflex/widget-utils": "^4.3.0",
|
|
19
19
|
"cuid": "^3.0.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@scaleflex/widget-core": "^0.0.3"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "712930995f6dfd4a0d874c0638dde61065fd0683"
|
|
25
25
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import Filerobot = require("@scaleflex/widget-core");
|
|
2
|
-
import XHRUploadLocale = require("./generatedLocale");
|
|
3
|
-
|
|
4
|
-
declare module XHRUpload {
|
|
5
|
-
export interface XHRUploadOptions extends Filerobot.PluginOptions {
|
|
6
|
-
limit?: number;
|
|
7
|
-
uploadQueryParams?: string;
|
|
8
|
-
bundle?: boolean;
|
|
9
|
-
formData?: boolean;
|
|
10
|
-
headers?: any;
|
|
11
|
-
fieldName?: string;
|
|
12
|
-
timeout?: number;
|
|
13
|
-
responseUrlFieldName?: string;
|
|
14
|
-
endpoint: string;
|
|
15
|
-
method?: "GET" | "POST" | "PUT" | "HEAD" | "get" | "post" | "put" | "head";
|
|
16
|
-
locale?: XHRUploadLocale;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
declare class XHRUpload extends Filerobot.Plugin<XHRUpload.XHRUploadOptions> {}
|
|
21
|
-
|
|
22
|
-
export = XHRUpload;
|
|
1
|
+
import Filerobot = require("@scaleflex/widget-core");
|
|
2
|
+
import XHRUploadLocale = require("./generatedLocale");
|
|
3
|
+
|
|
4
|
+
declare module XHRUpload {
|
|
5
|
+
export interface XHRUploadOptions extends Filerobot.PluginOptions {
|
|
6
|
+
limit?: number;
|
|
7
|
+
uploadQueryParams?: string;
|
|
8
|
+
bundle?: boolean;
|
|
9
|
+
formData?: boolean;
|
|
10
|
+
headers?: any;
|
|
11
|
+
fieldName?: string;
|
|
12
|
+
timeout?: number;
|
|
13
|
+
responseUrlFieldName?: string;
|
|
14
|
+
endpoint: string;
|
|
15
|
+
method?: "GET" | "POST" | "PUT" | "HEAD" | "get" | "post" | "put" | "head";
|
|
16
|
+
locale?: XHRUploadLocale;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare class XHRUpload extends Filerobot.Plugin<XHRUpload.XHRUploadOptions> {}
|
|
21
|
+
|
|
22
|
+
export = XHRUpload;
|