filestack-js 4.1.4 → 4.2.4
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/build/browser/filestack.esm.js +1 -1
- package/build/browser/filestack.esm.js.map +1 -1
- package/build/browser/filestack.min.js +1 -1
- package/build/browser/filestack.min.js.map +1 -1
- package/build/browser/filestack.umd.js +1 -1
- package/build/browser/filestack.umd.js.map +1 -1
- package/build/browser/manifest.json +2 -2
- package/build/main/config.js +2 -2
- package/build/main/index.d.ts +1 -1
- package/build/main/index.js +2 -2
- package/build/main/lib/api/store.js +9 -1
- package/build/main/lib/api/upload/file_tools.browser.d.ts +1 -1
- package/build/main/lib/api/upload/file_tools.browser.js +3 -3
- package/build/main/lib/api/upload/file_tools.node.d.ts +1 -1
- package/build/main/lib/api/upload/file_tools.node.js +4 -4
- package/build/main/lib/api/upload/types.d.ts +8 -1
- package/build/main/lib/api/upload/types.js +1 -1
- package/build/main/lib/api/upload/upload.d.ts +15 -2
- package/build/main/lib/api/upload/upload.js +17 -7
- package/build/main/lib/client.js +2 -2
- package/build/main/lib/client.spec.js +5 -7
- package/build/main/lib/picker.d.ts +5 -0
- package/build/main/lib/picker.js +1 -1
- package/build/main/lib/utils/index.browser.js +1 -1
- package/build/main/lib/utils/index.node.js +1 -1
- package/build/main/lib/utils/index.spec.browser.js +1 -1
- package/build/main/schema/picker.schema.d.ts +3 -4
- package/build/main/schema/picker.schema.js +4 -1
- package/build/main/schema/store.schema.d.ts +8 -0
- package/build/main/schema/store.schema.js +9 -1
- package/build/main/schema/upload.schema.d.ts +0 -4
- package/build/main/schema/upload.schema.js +1 -5
- package/build/module/config.js +2 -2
- package/build/module/index.d.ts +1 -1
- package/build/module/index.js +2 -2
- package/build/module/lib/api/store.js +9 -1
- package/build/module/lib/api/upload/file_tools.browser.d.ts +1 -1
- package/build/module/lib/api/upload/file_tools.browser.js +3 -3
- package/build/module/lib/api/upload/file_tools.node.d.ts +1 -1
- package/build/module/lib/api/upload/file_tools.node.js +4 -4
- package/build/module/lib/api/upload/types.d.ts +8 -1
- package/build/module/lib/api/upload/types.js +1 -1
- package/build/module/lib/api/upload/upload.d.ts +15 -2
- package/build/module/lib/api/upload/upload.js +17 -7
- package/build/module/lib/client.js +2 -2
- package/build/module/lib/client.spec.js +5 -7
- package/build/module/lib/picker.d.ts +5 -0
- package/build/module/lib/picker.js +1 -1
- package/build/module/lib/utils/index.browser.js +1 -1
- package/build/module/lib/utils/index.node.js +1 -1
- package/build/module/lib/utils/index.spec.browser.js +1 -1
- package/build/module/schema/picker.schema.d.ts +3 -4
- package/build/module/schema/picker.schema.js +4 -1
- package/build/module/schema/store.schema.d.ts +8 -0
- package/build/module/schema/store.schema.js +9 -1
- package/build/module/schema/upload.schema.d.ts +0 -4
- package/build/module/schema/upload.schema.js +1 -5
- package/package.json +1 -1
- package/src/config.ts +1 -1
- package/src/lib/api/store.ts +10 -1
- package/src/lib/api/upload/file_tools.browser.ts +2 -2
- package/src/lib/api/upload/file_tools.node.ts +3 -3
- package/src/lib/api/upload/types.ts +10 -2
- package/src/lib/api/upload/upload.ts +37 -6
- package/src/lib/client.spec.ts +4 -6
- package/src/lib/client.ts +1 -1
- package/src/lib/picker.ts +5 -0
- package/src/schema/picker.schema.ts +3 -0
- package/src/schema/store.schema.ts +8 -0
- package/src/schema/upload.schema.ts +0 -4
|
@@ -67,6 +67,22 @@ export class Upload extends EventEmitter {
|
|
|
67
67
|
*/
|
|
68
68
|
private overrideFileName;
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Mimetype of the file
|
|
72
|
+
*
|
|
73
|
+
* @private
|
|
74
|
+
* @memberof Upload
|
|
75
|
+
*/
|
|
76
|
+
private mimetype;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Alt Text of the file
|
|
80
|
+
*
|
|
81
|
+
* @private
|
|
82
|
+
* @memberof Upload
|
|
83
|
+
*/
|
|
84
|
+
private altText;
|
|
85
|
+
|
|
70
86
|
private lastProgress: ProgressEvent = {
|
|
71
87
|
totalBytes: 0,
|
|
72
88
|
totalPercent: 0,
|
|
@@ -102,6 +118,16 @@ export class Upload extends EventEmitter {
|
|
|
102
118
|
delete this.storeOptions.sanitizer;
|
|
103
119
|
}
|
|
104
120
|
|
|
121
|
+
if (storeOptions.altText) {
|
|
122
|
+
this.altText = storeOptions.altText;
|
|
123
|
+
delete this.storeOptions.altText;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (storeOptions.mimetype) {
|
|
127
|
+
this.mimetype = storeOptions.mimetype;
|
|
128
|
+
delete this.storeOptions.mimetype;
|
|
129
|
+
}
|
|
130
|
+
|
|
105
131
|
this.uploader = new S3Uploader(this.storeOptions, options.concurrency);
|
|
106
132
|
|
|
107
133
|
this.uploader.setRetryConfig({
|
|
@@ -199,16 +225,16 @@ export class Upload extends EventEmitter {
|
|
|
199
225
|
* Upload single file
|
|
200
226
|
*
|
|
201
227
|
* @param {(InputFile)} file
|
|
202
|
-
* @param {(string)} altText
|
|
203
228
|
* @returns {Promise<any>}
|
|
204
229
|
* @memberof Upload
|
|
205
230
|
*/
|
|
206
|
-
async upload(input: InputFile
|
|
231
|
+
async upload(input: InputFile): Promise<any> {
|
|
207
232
|
|
|
208
|
-
const f = await getFile(input, this.sanitizerOptions);
|
|
233
|
+
const f = await getFile(input, this.sanitizerOptions, this.mimetype);
|
|
209
234
|
f.customName = this.overrideFileName;
|
|
210
|
-
|
|
211
|
-
|
|
235
|
+
|
|
236
|
+
if (this.altText) {
|
|
237
|
+
f.alt = this.altText
|
|
212
238
|
}
|
|
213
239
|
|
|
214
240
|
this.uploader.addFile(f);
|
|
@@ -240,8 +266,13 @@ export class Upload extends EventEmitter {
|
|
|
240
266
|
continue;
|
|
241
267
|
}
|
|
242
268
|
|
|
243
|
-
const f = await getFile(input[i], this.sanitizerOptions);
|
|
269
|
+
const f = await getFile(input[i], this.sanitizerOptions, this.mimetype);
|
|
244
270
|
f.customName = this.overrideFileName;
|
|
271
|
+
|
|
272
|
+
if (this.altText) {
|
|
273
|
+
f.alt = this.altText
|
|
274
|
+
}
|
|
275
|
+
|
|
245
276
|
this.uploader.addFile(f);
|
|
246
277
|
}
|
|
247
278
|
|
package/src/lib/client.spec.ts
CHANGED
|
@@ -210,15 +210,13 @@ describe('client', () => {
|
|
|
210
210
|
|
|
211
211
|
expect(Upload.prototype.setToken).toHaveBeenCalledWith(token);
|
|
212
212
|
expect(Upload.prototype.setSecurity).toHaveBeenCalledWith(defaultSecurity);
|
|
213
|
-
expect(Upload.prototype.upload).toHaveBeenCalledWith(file
|
|
213
|
+
expect(Upload.prototype.upload).toHaveBeenCalledWith(file);
|
|
214
214
|
});
|
|
215
215
|
|
|
216
216
|
it('should be able to upload file with alt text', async () => {
|
|
217
217
|
const client = new Client(defaultApikey);
|
|
218
218
|
const file = 'anyFile';
|
|
219
|
-
const uploadOptions = {
|
|
220
|
-
altText: 'alt',
|
|
221
|
-
};
|
|
219
|
+
const uploadOptions = {};
|
|
222
220
|
const storeOptions = {};
|
|
223
221
|
const token = {};
|
|
224
222
|
|
|
@@ -233,7 +231,7 @@ describe('client', () => {
|
|
|
233
231
|
|
|
234
232
|
expect(Upload.prototype.setToken).toHaveBeenCalledWith(token);
|
|
235
233
|
expect(Upload.prototype.setSecurity).toHaveBeenCalledWith(defaultSecurity);
|
|
236
|
-
expect(Upload.prototype.upload).toHaveBeenCalledWith(file
|
|
234
|
+
expect(Upload.prototype.upload).toHaveBeenCalledWith(file);
|
|
237
235
|
});
|
|
238
236
|
|
|
239
237
|
it('should be able to upload file without token and security', async () => {
|
|
@@ -251,7 +249,7 @@ describe('client', () => {
|
|
|
251
249
|
urls: sessionURls,
|
|
252
250
|
});
|
|
253
251
|
|
|
254
|
-
expect(Upload.prototype.upload).toHaveBeenCalledWith(file
|
|
252
|
+
expect(Upload.prototype.upload).toHaveBeenCalledWith(file);
|
|
255
253
|
});
|
|
256
254
|
|
|
257
255
|
it('should emit error', async () => {
|
package/src/lib/client.ts
CHANGED
package/src/lib/picker.ts
CHANGED
|
@@ -736,6 +736,11 @@ export interface PickerOptions {
|
|
|
736
736
|
* Enable/Disable possibility to multiple file upload
|
|
737
737
|
*/
|
|
738
738
|
multipleFileUpload?: boolean;
|
|
739
|
+
/**
|
|
740
|
+
* Set your own Google Drive Picker App ID. Defaults to Filestack's.
|
|
741
|
+
* This is your Project Number from the Google Cloud console.
|
|
742
|
+
*/
|
|
743
|
+
googleDriveAppID?: string;
|
|
739
744
|
}
|
|
740
745
|
|
|
741
746
|
export interface PickerCropOptions {
|
|
@@ -28,6 +28,14 @@ export const StoreParamsSchema = {
|
|
|
28
28
|
format: 'callback',
|
|
29
29
|
}],
|
|
30
30
|
},
|
|
31
|
+
mimetype: {
|
|
32
|
+
type: ['string', 'null'],
|
|
33
|
+
maxLength: 255,
|
|
34
|
+
},
|
|
35
|
+
altText: {
|
|
36
|
+
type: ['string', 'null'],
|
|
37
|
+
maxLength: 125,
|
|
38
|
+
},
|
|
31
39
|
location: {
|
|
32
40
|
'$ref': 'locationsDef',
|
|
33
41
|
},
|