@redseat/api 0.0.12 → 0.0.13
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/dist/library.js +7 -0
- package/package.json +1 -1
package/dist/library.js
CHANGED
|
@@ -509,6 +509,7 @@ export class LibraryApi {
|
|
|
509
509
|
*/
|
|
510
510
|
async uploadMedia(data, options) {
|
|
511
511
|
// Validate: thumbnails can only be specified for encrypted libraries
|
|
512
|
+
console.log('uploadMedia', data.byteLength, options);
|
|
512
513
|
// Check library configuration
|
|
513
514
|
if (this.library.crypt === true) {
|
|
514
515
|
if (!this.key) {
|
|
@@ -516,6 +517,7 @@ export class LibraryApi {
|
|
|
516
517
|
}
|
|
517
518
|
}
|
|
518
519
|
// Normalize inputs to ArrayBuffer
|
|
520
|
+
console.log('normalize inputs');
|
|
519
521
|
let dataBuffer;
|
|
520
522
|
if (data instanceof Uint8Array) {
|
|
521
523
|
// Create a new ArrayBuffer and copy the data
|
|
@@ -526,6 +528,7 @@ export class LibraryApi {
|
|
|
526
528
|
const view = new Uint8Array(data);
|
|
527
529
|
dataBuffer = view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength);
|
|
528
530
|
}
|
|
531
|
+
console.log('dataBuffer', dataBuffer.byteLength);
|
|
529
532
|
let fileBlob;
|
|
530
533
|
let metadata = { ...options.metadata };
|
|
531
534
|
let filename;
|
|
@@ -572,6 +575,7 @@ export class LibraryApi {
|
|
|
572
575
|
// No encryption - use original filename
|
|
573
576
|
filename = options.metadata.name || 'file';
|
|
574
577
|
fileBlob = new Blob([dataBuffer], { type: options.fileMime });
|
|
578
|
+
console.log('fileBlob', fileBlob.size);
|
|
575
579
|
}
|
|
576
580
|
// Create FormData
|
|
577
581
|
const formData = new FormData();
|
|
@@ -579,6 +583,7 @@ export class LibraryApi {
|
|
|
579
583
|
formData.append('info', JSON.stringify({ ...metadata, size: fileBlob.size }));
|
|
580
584
|
// File should always be last in the FormData
|
|
581
585
|
formData.append('file', fileBlob, filename);
|
|
586
|
+
console.log('formData');
|
|
582
587
|
// Send POST request with progress tracking
|
|
583
588
|
const config = {};
|
|
584
589
|
if (options.progressCallback) {
|
|
@@ -588,7 +593,9 @@ export class LibraryApi {
|
|
|
588
593
|
}
|
|
589
594
|
};
|
|
590
595
|
}
|
|
596
|
+
console.log('postForm');
|
|
591
597
|
const res = await this.client.postForm(this.getUrl('/medias'), formData, config);
|
|
598
|
+
console.log('res', res.data);
|
|
592
599
|
return res.data;
|
|
593
600
|
}
|
|
594
601
|
}
|