@engine9-io/input-tools 1.7.4 → 1.7.5
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/file/FileUtilities.js +25 -0
- package/package.json +1 -1
package/file/FileUtilities.js
CHANGED
|
@@ -663,8 +663,33 @@ Worker.prototype.empty.metadata = {
|
|
|
663
663
|
},
|
|
664
664
|
};
|
|
665
665
|
|
|
666
|
+
Worker.prototype.remove = async function ({ filename }) {
|
|
667
|
+
if (!filename) throw new Error('filename is required');
|
|
668
|
+
if (typeof filename !== 'string') throw new Error(`filename isn't a string:${JSON.stringify(filename)}`);
|
|
669
|
+
if (filename.startsWith('s3://') || filename.startsWith('r2://')) {
|
|
670
|
+
let worker = null;
|
|
671
|
+
if (filename.startsWith('r2://')) {
|
|
672
|
+
worker = new R2Worker(this);
|
|
673
|
+
} else {
|
|
674
|
+
worker = new S3Worker(this);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
await worker.remove({ filename });
|
|
678
|
+
} else {
|
|
679
|
+
fsp.unlink(filename);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
return { removed: filename };
|
|
683
|
+
};
|
|
684
|
+
Worker.prototype.remove.metadata = {
|
|
685
|
+
options: {
|
|
686
|
+
filename: {},
|
|
687
|
+
},
|
|
688
|
+
};
|
|
689
|
+
|
|
666
690
|
Worker.prototype.move = async function ({ filename, target }) {
|
|
667
691
|
if (!target) throw new Error('target is required');
|
|
692
|
+
if (typeof target !== 'string') throw new Error(`target isn't a string:${JSON.stringify(target)}`);
|
|
668
693
|
if (target.startsWith('s3://') || target.startsWith('r2://')) {
|
|
669
694
|
if ((target.startsWith('s3://') && filename.startsWith('r2://'))
|
|
670
695
|
|| (target.startsWith('r2://') && filename.startsWith('s3://'))) {
|