@wix/media 1.0.50 → 1.0.52
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/cjs/index.js +5 -1
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/index.typings.js +5 -1
- package/build/cjs/index.typings.js.map +1 -1
- package/build/cjs/meta.js +5 -1
- package/build/cjs/meta.js.map +1 -1
- package/build/cjs/src/media-site-media-v1-file-descriptor.http.d.ts +83 -34
- package/build/cjs/src/media-site-media-v1-file-descriptor.http.js +433 -350
- package/build/cjs/src/media-site-media-v1-file-descriptor.http.js.map +1 -1
- package/build/cjs/src/media-site-media-v1-file-descriptor.meta.d.ts +1 -1
- package/build/cjs/src/media-site-media-v1-file-descriptor.meta.js +5 -1
- package/build/cjs/src/media-site-media-v1-file-descriptor.meta.js.map +1 -1
- package/build/cjs/src/media-site-media-v1-file-descriptor.public.d.ts +10 -10
- package/build/cjs/src/media-site-media-v1-file-descriptor.types.d.ts +5 -6
- package/build/cjs/src/media-site-media-v1-file-descriptor.types.js +10 -10
- package/build/cjs/src/media-site-media-v1-file-descriptor.types.js.map +1 -1
- package/build/cjs/src/media-site-media-v1-file-descriptor.universal.d.ts +126 -69
- package/build/cjs/src/media-site-media-v1-file-descriptor.universal.js +227 -99
- package/build/cjs/src/media-site-media-v1-file-descriptor.universal.js.map +1 -1
- package/build/cjs/src/media-site-media-v1-folder.http.js +84 -89
- package/build/cjs/src/media-site-media-v1-folder.http.js.map +1 -1
- package/build/cjs/src/media-site-media-v1-folder.meta.d.ts +1 -1
- package/build/cjs/src/media-site-media-v1-folder.meta.js +5 -1
- package/build/cjs/src/media-site-media-v1-folder.meta.js.map +1 -1
- package/build/cjs/src/media-site-media-v1-folder.public.d.ts +5 -5
- package/build/cjs/src/media-site-media-v1-folder.types.d.ts +4 -5
- package/build/cjs/src/media-site-media-v1-folder.types.js +4 -4
- package/build/cjs/src/media-site-media-v1-folder.types.js.map +1 -1
- package/build/cjs/src/media-site-media-v1-folder.universal.d.ts +4 -5
- package/build/cjs/src/media-site-media-v1-folder.universal.js +74 -37
- package/build/cjs/src/media-site-media-v1-folder.universal.js.map +1 -1
- package/build/es/src/media-site-media-v1-file-descriptor.http.d.ts +83 -34
- package/build/es/src/media-site-media-v1-file-descriptor.http.js +433 -350
- package/build/es/src/media-site-media-v1-file-descriptor.http.js.map +1 -1
- package/build/es/src/media-site-media-v1-file-descriptor.meta.d.ts +1 -1
- package/build/es/src/media-site-media-v1-file-descriptor.public.d.ts +10 -10
- package/build/es/src/media-site-media-v1-file-descriptor.types.d.ts +5 -6
- package/build/es/src/media-site-media-v1-file-descriptor.types.js.map +1 -1
- package/build/es/src/media-site-media-v1-file-descriptor.universal.d.ts +126 -69
- package/build/es/src/media-site-media-v1-file-descriptor.universal.js +213 -89
- package/build/es/src/media-site-media-v1-file-descriptor.universal.js.map +1 -1
- package/build/es/src/media-site-media-v1-folder.http.js +84 -89
- package/build/es/src/media-site-media-v1-folder.http.js.map +1 -1
- package/build/es/src/media-site-media-v1-folder.meta.d.ts +1 -1
- package/build/es/src/media-site-media-v1-folder.public.d.ts +5 -5
- package/build/es/src/media-site-media-v1-folder.types.d.ts +4 -5
- package/build/es/src/media-site-media-v1-folder.types.js.map +1 -1
- package/build/es/src/media-site-media-v1-folder.universal.d.ts +4 -5
- package/build/es/src/media-site-media-v1-folder.universal.js +66 -33
- package/build/es/src/media-site-media-v1-folder.universal.js.map +1 -1
- package/package.json +7 -3
|
@@ -7,7 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { serializer
|
|
10
|
+
import { serializer } from '@wix/metro-runtime/velo';
|
|
11
|
+
import { transformError as sdkTransformError } from '@wix/sdk-runtime/transform-error';
|
|
11
12
|
import * as ambassadorWixMediaSiteMediaV1FileDescriptor from './media-site-media-v1-file-descriptor.http';
|
|
12
13
|
let __verbose = false;
|
|
13
14
|
function __log(...args) {
|
|
@@ -170,6 +171,8 @@ const _updateFileDescriptorResponse = { file: '_fileDescriptor' };
|
|
|
170
171
|
/**
|
|
171
172
|
* Generates a URL for downloading a compressed file containing specific files in the Media Manager.
|
|
172
173
|
*
|
|
174
|
+
* The `generateFilesDownloadUrl()` function returns a Promise that resolves to a download URL.
|
|
175
|
+
*
|
|
173
176
|
* The compressed file can contain up to 1000 files.
|
|
174
177
|
* @param fileIds - IDs of the files to download.
|
|
175
178
|
* @public
|
|
@@ -214,9 +217,11 @@ export function generateFilesDownloadUrl(fileIds) {
|
|
|
214
217
|
return fromJSON(result.data);
|
|
215
218
|
}
|
|
216
219
|
catch (err) {
|
|
217
|
-
const transformedError =
|
|
218
|
-
|
|
219
|
-
|
|
220
|
+
const transformedError = sdkTransformError(err, {
|
|
221
|
+
spreadPathsToArguments: {},
|
|
222
|
+
explicitPathsToArguments: { fileIds: '$[0]' },
|
|
223
|
+
singleArgumentUnchanged: false,
|
|
224
|
+
}, ['fileIds']);
|
|
220
225
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
221
226
|
throw transformedError;
|
|
222
227
|
}
|
|
@@ -225,10 +230,12 @@ export function generateFilesDownloadUrl(fileIds) {
|
|
|
225
230
|
/**
|
|
226
231
|
* Generates one or more temporary URLs for downloading a specific file in the Media Manager.
|
|
227
232
|
*
|
|
233
|
+
* The `generateFileDownloadUrl()` function returns a Promise that resolves to an array containing download URLs for the assets specified in the options parameter.
|
|
234
|
+
*
|
|
228
235
|
* To download different assets of the file, use the `assetKeys` parameter which generates a download URL for each asset.
|
|
229
|
-
* If no
|
|
236
|
+
* If no asset key is specified, it defaults to `src`, which generates one download URL in the original file's format and quality.
|
|
230
237
|
*
|
|
231
|
-
* Use this endpoint to grant external clients access to a private media file. Use the `expirationInMinutes` parameter to set the URL expiration time, and the `expirationRedirectUrl` parameter to add a redirect
|
|
238
|
+
* Use this endpoint to grant external clients access to a private media file. Use the `expirationInMinutes` parameter to set the URL expiration time, and the `expirationRedirectUrl` parameter to add a redirect URL when the URL expires.
|
|
232
239
|
* @param fileId - File ID.
|
|
233
240
|
* @public
|
|
234
241
|
* @requiredField fileId
|
|
@@ -279,10 +286,18 @@ export function generateFileDownloadUrl(fileId, options) {
|
|
|
279
286
|
return fromJSON(result.data);
|
|
280
287
|
}
|
|
281
288
|
catch (err) {
|
|
282
|
-
const transformedError =
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
289
|
+
const transformedError = sdkTransformError(err, {
|
|
290
|
+
spreadPathsToArguments: {},
|
|
291
|
+
explicitPathsToArguments: {
|
|
292
|
+
fileId: '$[0]',
|
|
293
|
+
downloadFileName: '$[1].downloadFileName',
|
|
294
|
+
expirationInMinutes: '$[1].expirationInMinutes',
|
|
295
|
+
expirationRedirectUrl: '$[1].expirationRedirectUrl',
|
|
296
|
+
assetKeys: '$[1].assetKeys',
|
|
297
|
+
contentDisposition: '$[1].contentDisposition',
|
|
298
|
+
},
|
|
299
|
+
singleArgumentUnchanged: false,
|
|
300
|
+
}, ['fileId', 'options']);
|
|
286
301
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
287
302
|
throw transformedError;
|
|
288
303
|
}
|
|
@@ -290,6 +305,11 @@ export function generateFileDownloadUrl(fileId, options) {
|
|
|
290
305
|
}
|
|
291
306
|
/**
|
|
292
307
|
* Gets information about the specified file in the Media Manager.
|
|
308
|
+
*
|
|
309
|
+
*
|
|
310
|
+
* The `getFileDescriptor()` function returns a Promise that resolves to the specified file's descriptor.
|
|
311
|
+
*
|
|
312
|
+
* Use `getFileDescriptors()` to get multiple file descriptors at once.
|
|
293
313
|
* @param fileId - File ID.
|
|
294
314
|
* @public
|
|
295
315
|
* @documentationMaturity preview
|
|
@@ -341,9 +361,11 @@ export function getFileDescriptor(fileId) {
|
|
|
341
361
|
return fromJSON(result.data);
|
|
342
362
|
}
|
|
343
363
|
catch (err) {
|
|
344
|
-
const transformedError =
|
|
345
|
-
|
|
346
|
-
|
|
364
|
+
const transformedError = sdkTransformError(err, {
|
|
365
|
+
spreadPathsToArguments: {},
|
|
366
|
+
explicitPathsToArguments: { fileId: '$[0]' },
|
|
367
|
+
singleArgumentUnchanged: false,
|
|
368
|
+
}, ['fileId']);
|
|
347
369
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
348
370
|
throw transformedError;
|
|
349
371
|
}
|
|
@@ -351,6 +373,11 @@ export function getFileDescriptor(fileId) {
|
|
|
351
373
|
}
|
|
352
374
|
/**
|
|
353
375
|
* Gets information about the specified files in the Media Manager.
|
|
376
|
+
*
|
|
377
|
+
*
|
|
378
|
+
* The `getFileDescriptors()` function returns a Promise that resolves to an array containing the specified files' descriptors.
|
|
379
|
+
*
|
|
380
|
+
* Use `getFileDescriptor()` to get a single file descriptor.
|
|
354
381
|
* @param fileIds - File IDs.
|
|
355
382
|
* @public
|
|
356
383
|
* @documentationMaturity preview
|
|
@@ -401,16 +428,21 @@ export function getFileDescriptors(fileIds) {
|
|
|
401
428
|
return fromJSON(result.data);
|
|
402
429
|
}
|
|
403
430
|
catch (err) {
|
|
404
|
-
const transformedError =
|
|
405
|
-
|
|
406
|
-
|
|
431
|
+
const transformedError = sdkTransformError(err, {
|
|
432
|
+
spreadPathsToArguments: {},
|
|
433
|
+
explicitPathsToArguments: { fileIds: '$[0]' },
|
|
434
|
+
singleArgumentUnchanged: false,
|
|
435
|
+
}, ['fileIds']);
|
|
407
436
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
408
437
|
throw transformedError;
|
|
409
438
|
}
|
|
410
439
|
});
|
|
411
440
|
}
|
|
412
441
|
/**
|
|
413
|
-
* Updates a file.
|
|
442
|
+
* Updates a file.
|
|
443
|
+
*
|
|
444
|
+
*
|
|
445
|
+
* The `updateFileDescriptor()` function returns a Promise that resolves to the updated file's descriptor.
|
|
414
446
|
*
|
|
415
447
|
* You can use the `parentFolderId` parameter to move a file from its current folder to a different folder.
|
|
416
448
|
* @param _id - File ID. Generated when a file is uploaded to the Media Manager.
|
|
@@ -470,10 +502,11 @@ export function updateFileDescriptor(_id, file) {
|
|
|
470
502
|
return fromJSON(result.data);
|
|
471
503
|
}
|
|
472
504
|
catch (err) {
|
|
473
|
-
const transformedError =
|
|
474
|
-
'
|
|
475
|
-
'file',
|
|
476
|
-
|
|
505
|
+
const transformedError = sdkTransformError(err, {
|
|
506
|
+
spreadPathsToArguments: { file: '$[1]' },
|
|
507
|
+
explicitPathsToArguments: { 'file.id': '$[0]' },
|
|
508
|
+
singleArgumentUnchanged: false,
|
|
509
|
+
}, ['_id', 'file']);
|
|
477
510
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
478
511
|
throw transformedError;
|
|
479
512
|
}
|
|
@@ -482,9 +515,11 @@ export function updateFileDescriptor(_id, file) {
|
|
|
482
515
|
/**
|
|
483
516
|
* Generates an upload URL to allow external clients to upload a file to the Media Manager.
|
|
484
517
|
*
|
|
518
|
+
* The `generateFileUploadUrl()` function returns a Promise that resolves to an upload URL.
|
|
519
|
+
*
|
|
485
520
|
* To learn how external clients can use the generated upload URL in the response to upload a file to the Media Manager, see the Upload API article.
|
|
486
521
|
*
|
|
487
|
-
* > **Note:** Any interruption in the upload process stops the file upload. For files larger than 10MB, or when network connection is poor, use
|
|
522
|
+
* > **Note:** Any interruption in the upload process stops the file upload. For files larger than 10MB, or when network connection is poor, use `generateFileResumableUploadUrl()` instead. With the resumable upload URL, any interruption in the upload process pauses the file upload, and resumes the file upload process after the interruption.
|
|
488
523
|
* @param mimeType - File mime type.
|
|
489
524
|
* @public
|
|
490
525
|
* @documentationMaturity preview
|
|
@@ -537,19 +572,30 @@ export function generateFileUploadUrl(mimeType, options) {
|
|
|
537
572
|
return fromJSON(result.data);
|
|
538
573
|
}
|
|
539
574
|
catch (err) {
|
|
540
|
-
const transformedError =
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
575
|
+
const transformedError = sdkTransformError(err, {
|
|
576
|
+
spreadPathsToArguments: {},
|
|
577
|
+
explicitPathsToArguments: {
|
|
578
|
+
mimeType: '$[0]',
|
|
579
|
+
fileName: '$[1].fileName',
|
|
580
|
+
sizeInBytes: '$[1].sizeInBytes',
|
|
581
|
+
parentFolderId: '$[1].parentFolderId',
|
|
582
|
+
private: '$[1].private',
|
|
583
|
+
labels: '$[1].labels',
|
|
584
|
+
externalInfo: '$[1].externalInfo',
|
|
585
|
+
},
|
|
586
|
+
singleArgumentUnchanged: false,
|
|
587
|
+
}, ['mimeType', 'options']);
|
|
544
588
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
545
589
|
throw transformedError;
|
|
546
590
|
}
|
|
547
591
|
});
|
|
548
592
|
}
|
|
549
593
|
/**
|
|
550
|
-
* Generates a resumable upload URL to allow external clients to
|
|
594
|
+
* Generates a resumable upload URL to allow external clients to upload large files over 10MB to the Media Manager.
|
|
551
595
|
*
|
|
552
|
-
*
|
|
596
|
+
* The `generateFileResumableUploadUrl()` function returns a Promise that resolves to an upload URL, token, and protocol.
|
|
597
|
+
*
|
|
598
|
+
* When using the resumable upload URL, any interruptions will pause the file upload process, which automatically resumes once the interruption is resolved. The resumable upload URL is also helpful when network connection is poor.
|
|
553
599
|
*
|
|
554
600
|
* To learn how external clients can use the generated upload URL in the response to upload large files to the Media Manager, see the Resumable Upload API article.
|
|
555
601
|
* @param mimeType - File mime type.
|
|
@@ -604,29 +650,37 @@ export function generateFileResumableUploadUrl(mimeType, options) {
|
|
|
604
650
|
return fromJSON(result.data);
|
|
605
651
|
}
|
|
606
652
|
catch (err) {
|
|
607
|
-
const transformedError =
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
653
|
+
const transformedError = sdkTransformError(err, {
|
|
654
|
+
spreadPathsToArguments: {},
|
|
655
|
+
explicitPathsToArguments: {
|
|
656
|
+
mimeType: '$[0]',
|
|
657
|
+
fileName: '$[1].fileName',
|
|
658
|
+
sizeInBytes: '$[1].sizeInBytes',
|
|
659
|
+
parentFolderId: '$[1].parentFolderId',
|
|
660
|
+
private: '$[1].private',
|
|
661
|
+
labels: '$[1].labels',
|
|
662
|
+
uploadProtocol: '$[1].uploadProtocol',
|
|
663
|
+
},
|
|
664
|
+
singleArgumentUnchanged: false,
|
|
665
|
+
}, ['mimeType', 'options']);
|
|
611
666
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
612
667
|
throw transformedError;
|
|
613
668
|
}
|
|
614
669
|
});
|
|
615
670
|
}
|
|
616
671
|
/**
|
|
617
|
-
* Imports a file to the Media Manager using an external
|
|
672
|
+
* Imports a file to the Media Manager using an external URL.
|
|
673
|
+
*
|
|
674
|
+
* The `importFile()` function returns a Promise that resolves to the imported file's descriptor.
|
|
618
675
|
*
|
|
619
|
-
* This function returns information about the imported file.
|
|
676
|
+
* This function returns information about the imported file. Importing a file is the method through which you can add files to the Media Manager.
|
|
620
677
|
* Use the `parentFolderId` parameter to specify which folder you want the file to be imported to.
|
|
621
678
|
* If no folder is specified, the file is imported to the `media-root` folder.
|
|
622
679
|
*
|
|
623
|
-
* To import a file, you need to
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
* >**Note:** The `media` property isn't returned in the `files` response object.
|
|
629
|
-
*
|
|
680
|
+
* To import a file, you need to pass one of the following:
|
|
681
|
+
* - The file's [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) in the `mimeType` parameter of the request. For example, `'image/png'`.
|
|
682
|
+
* - The file's name and extension. For example, `'my-image.png'`.
|
|
683
|
+
* - If you don't know the file's extension or MIME type, its [media type](https://support.wix.com/en/article/wix-media-supported-media-file-types-and-file-sizes) in the `mediaType` parameter of the request. For example, `'IMAGE'`. Note that this option only works if the server hosting the media allows a 'HEAD' request.
|
|
630
684
|
* @param url - Publicly accessible external file URL.
|
|
631
685
|
* @public
|
|
632
686
|
* @documentationMaturity preview
|
|
@@ -688,10 +742,22 @@ export function importFile(url, options) {
|
|
|
688
742
|
return fromJSON(result.data);
|
|
689
743
|
}
|
|
690
744
|
catch (err) {
|
|
691
|
-
const transformedError =
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
745
|
+
const transformedError = sdkTransformError(err, {
|
|
746
|
+
spreadPathsToArguments: {},
|
|
747
|
+
explicitPathsToArguments: {
|
|
748
|
+
url: '$[0]',
|
|
749
|
+
mediaType: '$[1].mediaType',
|
|
750
|
+
displayName: '$[1].displayName',
|
|
751
|
+
parentFolderId: '$[1].parentFolderId',
|
|
752
|
+
private: '$[1].private',
|
|
753
|
+
labels: '$[1].labels',
|
|
754
|
+
mimeType: '$[1].mimeType',
|
|
755
|
+
externalInfo: '$[1].externalInfo',
|
|
756
|
+
urlParams: '$[1].urlParams',
|
|
757
|
+
urlHeaders: '$[1].urlHeaders',
|
|
758
|
+
},
|
|
759
|
+
singleArgumentUnchanged: false,
|
|
760
|
+
}, ['url', 'options']);
|
|
695
761
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
696
762
|
throw transformedError;
|
|
697
763
|
}
|
|
@@ -702,15 +768,17 @@ export function importFile(url, options) {
|
|
|
702
768
|
* > This function has been replaced with `bulkImportFile()`, and will be removed on March 31, 2024.
|
|
703
769
|
*
|
|
704
770
|
*
|
|
771
|
+
* The `bulkImportFiles()` function returns a Promise that resolves to an array of the imported files' descriptors.
|
|
772
|
+
*
|
|
705
773
|
* Imports a bulk of files to the Media Manager using external urls.
|
|
706
774
|
*
|
|
707
775
|
* Returns information about the imported files. Use the `parentFolderId` parameter to specify in which folder you want each file to be imported.
|
|
708
776
|
* If no folder is specified, the file is imported to the `media-root` folder.
|
|
709
777
|
*
|
|
710
|
-
* To import
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
778
|
+
* To import a file, you need to pass one of the following:
|
|
779
|
+
* - The file's [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) in the `mimeType` parameter of the request. For example, `'image/png'`.
|
|
780
|
+
* - The file's name and extension. For example, `'my-image.png'`.
|
|
781
|
+
* - If you don't know the file's extension or MIME type, its [media type](https://support.wix.com/en/article/wix-media-supported-media-file-types-and-file-sizes) in the `mediaType` parameter of the request. For example, `'IMAGE'`. Note that this option only works if the server hosting the media allows a 'HEAD' request.
|
|
714
782
|
*
|
|
715
783
|
* >**Note:** The `media` property isn't returned in the `files` response object.
|
|
716
784
|
* @param importFileRequests - Information about the files to import.
|
|
@@ -764,31 +832,34 @@ export function bulkImportFiles(importFileRequests) {
|
|
|
764
832
|
return fromJSON(result.data);
|
|
765
833
|
}
|
|
766
834
|
catch (err) {
|
|
767
|
-
const transformedError =
|
|
768
|
-
|
|
769
|
-
|
|
835
|
+
const transformedError = sdkTransformError(err, {
|
|
836
|
+
spreadPathsToArguments: {},
|
|
837
|
+
explicitPathsToArguments: { importFileRequests: '$[0]' },
|
|
838
|
+
singleArgumentUnchanged: false,
|
|
839
|
+
}, ['importFileRequests']);
|
|
770
840
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
771
841
|
throw transformedError;
|
|
772
842
|
}
|
|
773
843
|
});
|
|
774
844
|
}
|
|
775
845
|
/**
|
|
776
|
-
* Imports a bulk of files to the Media Manager using external urls.
|
|
846
|
+
* Imports a bulk of files to the Media Manager using external urls.
|
|
777
847
|
*
|
|
778
|
-
*
|
|
779
|
-
* If no folder is specified, the file is imported to the `media-root` folder.
|
|
848
|
+
* The `bulkImportFile()` function returns a Promise that resolves to an object containing bulk import metadata and an array of imported files' descriptors and metadata.
|
|
780
849
|
*
|
|
781
|
-
*
|
|
782
|
-
*
|
|
783
|
-
* 2. Pass each file's name and extension. For example, 'my-image.png'.
|
|
784
|
-
* 3. If you don't know a file's extension or MIME type, pass its media type in the `mediaType` parameter of the request. For example, 'IMAGE'. Note that this option only works if the server hosting the media allows a 'HEAD' request.
|
|
850
|
+
* Returns information about the imported files. Use the `parentFolderId` parameter to specify in which folder you want each file to be imported.
|
|
851
|
+
* If no folder is specified, the file is imported to the `media-root` folder.
|
|
785
852
|
*
|
|
786
|
-
*
|
|
853
|
+
* To import a file, you need to pass one of the following:
|
|
854
|
+
* - The file's [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) in the `mimeType` parameter of the request. For example, `'image/png'`.
|
|
855
|
+
* - The file's name and extension. For example, `'my-image.png'`.
|
|
856
|
+
* - If you don't know the file's extension or MIME type, its [media type](https://support.wix.com/en/article/wix-media-supported-media-file-types-and-file-sizes) in the `mediaType` parameter of the request. For example, `'IMAGE'`. Note that this option only works if the server hosting the media allows a 'HEAD' request.
|
|
787
857
|
* @param importFileRequests - Information about the files to import.
|
|
788
858
|
* @public
|
|
789
859
|
* @documentationMaturity preview
|
|
790
860
|
* @requiredField importFileRequests
|
|
791
861
|
* @requiredField importFileRequests.url
|
|
862
|
+
* @param options - Options to include the file descriptor in the response.
|
|
792
863
|
* @permissionScope Manage Bookings Services and Settings
|
|
793
864
|
* @permissionScope Manage Media Manager
|
|
794
865
|
* @applicableIdentity APP
|
|
@@ -838,10 +909,14 @@ export function bulkImportFile(importFileRequests, options) {
|
|
|
838
909
|
return fromJSON(result.data);
|
|
839
910
|
}
|
|
840
911
|
catch (err) {
|
|
841
|
-
const transformedError =
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
912
|
+
const transformedError = sdkTransformError(err, {
|
|
913
|
+
spreadPathsToArguments: {},
|
|
914
|
+
explicitPathsToArguments: {
|
|
915
|
+
importFileRequests: '$[0]',
|
|
916
|
+
returnEntity: '$[1].returnEntity',
|
|
917
|
+
},
|
|
918
|
+
singleArgumentUnchanged: false,
|
|
919
|
+
}, ['importFileRequests', 'options']);
|
|
845
920
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
846
921
|
throw transformedError;
|
|
847
922
|
}
|
|
@@ -850,7 +925,11 @@ export function bulkImportFile(importFileRequests, options) {
|
|
|
850
925
|
/**
|
|
851
926
|
* Retrieves a list of files in the Media Manager.
|
|
852
927
|
*
|
|
928
|
+
* The `listFiles()` function returns a Promise that resolves to an array of the specified files' descriptors and cursor information.
|
|
929
|
+
*
|
|
853
930
|
* To retrieve a list of files within a specific folder in the Media Manager, pass the folder's ID in the `parentFolderId` parameter. If no folder is specified, the endpoint retrieves only the list of files in the root folder of the Media Manager.
|
|
931
|
+
*
|
|
932
|
+
* To retrieve a list of (non-permanently) deleted files, use the `listDeletedFiles()` function.
|
|
854
933
|
* @public
|
|
855
934
|
* @documentationMaturity preview
|
|
856
935
|
* @param options - Options to use when listing media files.
|
|
@@ -906,9 +985,17 @@ export function listFiles(options) {
|
|
|
906
985
|
return fromJSON(result.data);
|
|
907
986
|
}
|
|
908
987
|
catch (err) {
|
|
909
|
-
const transformedError =
|
|
910
|
-
|
|
911
|
-
|
|
988
|
+
const transformedError = sdkTransformError(err, {
|
|
989
|
+
spreadPathsToArguments: {},
|
|
990
|
+
explicitPathsToArguments: {
|
|
991
|
+
parentFolderId: '$[0].parentFolderId',
|
|
992
|
+
mediaTypes: '$[0].mediaTypes',
|
|
993
|
+
private: '$[0].private',
|
|
994
|
+
sort: '$[0].sort',
|
|
995
|
+
paging: '$[0].paging',
|
|
996
|
+
},
|
|
997
|
+
singleArgumentUnchanged: false,
|
|
998
|
+
}, ['options']);
|
|
912
999
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
913
1000
|
throw transformedError;
|
|
914
1001
|
}
|
|
@@ -917,7 +1004,9 @@ export function listFiles(options) {
|
|
|
917
1004
|
/**
|
|
918
1005
|
* Searches all folders in the Media Manager and returns a list of files that match the terms specified in the optional parameters.
|
|
919
1006
|
*
|
|
920
|
-
*
|
|
1007
|
+
* The `searchFiles()` function returns a Promise that resolves to an array of the specified files' descriptors and cursor information.
|
|
1008
|
+
*
|
|
1009
|
+
* If no parameters are specified, the function returns all files in the `MEDIA_ROOT` folder.
|
|
921
1010
|
* @public
|
|
922
1011
|
* @documentationMaturity preview
|
|
923
1012
|
* @param options - Options to specify which folders to search.
|
|
@@ -974,9 +1063,18 @@ export function searchFiles(options) {
|
|
|
974
1063
|
return fromJSON(result.data);
|
|
975
1064
|
}
|
|
976
1065
|
catch (err) {
|
|
977
|
-
const transformedError =
|
|
978
|
-
|
|
979
|
-
|
|
1066
|
+
const transformedError = sdkTransformError(err, {
|
|
1067
|
+
spreadPathsToArguments: {},
|
|
1068
|
+
explicitPathsToArguments: {
|
|
1069
|
+
search: '$[0].search',
|
|
1070
|
+
rootFolder: '$[0].rootFolder',
|
|
1071
|
+
mediaTypes: '$[0].mediaTypes',
|
|
1072
|
+
private: '$[0].private',
|
|
1073
|
+
sort: '$[0].sort',
|
|
1074
|
+
paging: '$[0].paging',
|
|
1075
|
+
},
|
|
1076
|
+
singleArgumentUnchanged: false,
|
|
1077
|
+
}, ['options']);
|
|
980
1078
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
981
1079
|
throw transformedError;
|
|
982
1080
|
}
|
|
@@ -984,6 +1082,11 @@ export function searchFiles(options) {
|
|
|
984
1082
|
}
|
|
985
1083
|
/**
|
|
986
1084
|
* Generates a URL for streaming a specific video file in the Media Manager.
|
|
1085
|
+
*
|
|
1086
|
+
*
|
|
1087
|
+
* The `generateVideoStreamingUrl()` function returns a Promise that resolves to a download URL and its asset key.
|
|
1088
|
+
*
|
|
1089
|
+
* To stream different assets of the file, use the `assetKeys` parameter which generates a video streaming URL for each asset. If no asset key is specified, it defaults to `src`, which generates one video streaming URL in the original file's format and quality.
|
|
987
1090
|
* @param fileId - File ID.
|
|
988
1091
|
* @public
|
|
989
1092
|
* @documentationMaturity preview
|
|
@@ -1029,10 +1132,11 @@ export function generateVideoStreamingUrl(fileId, options) {
|
|
|
1029
1132
|
return fromJSON(result.data);
|
|
1030
1133
|
}
|
|
1031
1134
|
catch (err) {
|
|
1032
|
-
const transformedError =
|
|
1033
|
-
|
|
1034
|
-
'
|
|
1035
|
-
|
|
1135
|
+
const transformedError = sdkTransformError(err, {
|
|
1136
|
+
spreadPathsToArguments: {},
|
|
1137
|
+
explicitPathsToArguments: { fileId: '$[0]', format: '$[1].format' },
|
|
1138
|
+
singleArgumentUnchanged: false,
|
|
1139
|
+
}, ['fileId', 'options']);
|
|
1036
1140
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1037
1141
|
throw transformedError;
|
|
1038
1142
|
}
|
|
@@ -1042,7 +1146,9 @@ export function generateVideoStreamingUrl(fileId, options) {
|
|
|
1042
1146
|
* Deletes the specified files from the Media Manager.
|
|
1043
1147
|
*
|
|
1044
1148
|
*
|
|
1045
|
-
* The
|
|
1149
|
+
* The `bulkDeleteFiles()` function returns a Promise that resolves when the files are deleted.
|
|
1150
|
+
*
|
|
1151
|
+
* The deleted files are moved to the Media Manager's trash bin (`TRASH_ROOT` folder) unless permanently deleted. To permanently delete files, pass the `permanent` parameter with the value `true`. Permanently deleting files isn't reversible, so make sure that these files aren't being used in a site or in any other way as the files will no longer be accessible.
|
|
1046
1152
|
*
|
|
1047
1153
|
* >**Notes:**
|
|
1048
1154
|
* > - The specified files can be from different folders.
|
|
@@ -1094,13 +1200,16 @@ export function bulkDeleteFiles(fileIds, options) {
|
|
|
1094
1200
|
try {
|
|
1095
1201
|
const result = yield httpClient.request(reqOpts);
|
|
1096
1202
|
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
1097
|
-
return fromJSON(result.data);
|
|
1098
1203
|
}
|
|
1099
1204
|
catch (err) {
|
|
1100
|
-
const transformedError =
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1205
|
+
const transformedError = sdkTransformError(err, {
|
|
1206
|
+
spreadPathsToArguments: {},
|
|
1207
|
+
explicitPathsToArguments: {
|
|
1208
|
+
fileIds: '$[0]',
|
|
1209
|
+
permanent: '$[1].permanent',
|
|
1210
|
+
},
|
|
1211
|
+
singleArgumentUnchanged: false,
|
|
1212
|
+
}, ['fileIds', 'options']);
|
|
1104
1213
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1105
1214
|
throw transformedError;
|
|
1106
1215
|
}
|
|
@@ -1108,6 +1217,8 @@ export function bulkDeleteFiles(fileIds, options) {
|
|
|
1108
1217
|
}
|
|
1109
1218
|
/**
|
|
1110
1219
|
* Restores the specified files from the Media Manager's trash bin, and moves them to their original locations in the Media Manager.
|
|
1220
|
+
*
|
|
1221
|
+
* The `bulkRestoreFilesFromTrashBin()` function returns a Promise that resolves when the files have been restored.
|
|
1111
1222
|
* @param fileIds - IDs of the files to restore from the Media Manager's trash bin.
|
|
1112
1223
|
* @public
|
|
1113
1224
|
* @documentationMaturity preview
|
|
@@ -1148,12 +1259,13 @@ export function bulkRestoreFilesFromTrashBin(fileIds) {
|
|
|
1148
1259
|
try {
|
|
1149
1260
|
const result = yield httpClient.request(reqOpts);
|
|
1150
1261
|
(_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
|
|
1151
|
-
return fromJSON(result.data);
|
|
1152
1262
|
}
|
|
1153
1263
|
catch (err) {
|
|
1154
|
-
const transformedError =
|
|
1155
|
-
|
|
1156
|
-
|
|
1264
|
+
const transformedError = sdkTransformError(err, {
|
|
1265
|
+
spreadPathsToArguments: {},
|
|
1266
|
+
explicitPathsToArguments: { fileIds: '$[0]' },
|
|
1267
|
+
singleArgumentUnchanged: false,
|
|
1268
|
+
}, ['fileIds']);
|
|
1157
1269
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1158
1270
|
throw transformedError;
|
|
1159
1271
|
}
|
|
@@ -1162,7 +1274,11 @@ export function bulkRestoreFilesFromTrashBin(fileIds) {
|
|
|
1162
1274
|
/**
|
|
1163
1275
|
* Retrieves a list of files in the Media Manager's trash bin.
|
|
1164
1276
|
*
|
|
1165
|
-
*
|
|
1277
|
+
* The `listDeletedFiles()` function returns a Promise that resolves to an array of the specified deleted files' descriptors and cursor information.
|
|
1278
|
+
*
|
|
1279
|
+
* >**Note:** The Media Manager's trash bin (`TRASH_ROOT` folder) only contains temporarily deleted files, not permanently deleted files.
|
|
1280
|
+
*
|
|
1281
|
+
* To retrieve a list of non-deleted files, use the `listFiles()` function.
|
|
1166
1282
|
* @public
|
|
1167
1283
|
* @documentationMaturity preview
|
|
1168
1284
|
* @param options - Options to use when listing deleted files from the trash bin.
|
|
@@ -1218,9 +1334,17 @@ export function listDeletedFiles(options) {
|
|
|
1218
1334
|
return fromJSON(result.data);
|
|
1219
1335
|
}
|
|
1220
1336
|
catch (err) {
|
|
1221
|
-
const transformedError =
|
|
1222
|
-
|
|
1223
|
-
|
|
1337
|
+
const transformedError = sdkTransformError(err, {
|
|
1338
|
+
spreadPathsToArguments: {},
|
|
1339
|
+
explicitPathsToArguments: {
|
|
1340
|
+
parentFolderId: '$[0].parentFolderId',
|
|
1341
|
+
mediaTypes: '$[0].mediaTypes',
|
|
1342
|
+
private: '$[0].private',
|
|
1343
|
+
sort: '$[0].sort',
|
|
1344
|
+
paging: '$[0].paging',
|
|
1345
|
+
},
|
|
1346
|
+
singleArgumentUnchanged: false,
|
|
1347
|
+
}, ['options']);
|
|
1224
1348
|
(_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
|
|
1225
1349
|
throw transformedError;
|
|
1226
1350
|
}
|