@e-mc/cloud 0.0.1
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/LICENSE +11 -0
- package/README.md +5 -0
- package/atlas/index.js +193 -0
- package/aws/download/index.js +44 -0
- package/aws/index.js +381 -0
- package/aws/upload/index.js +137 -0
- package/aws-v3/download/index.js +42 -0
- package/aws-v3/index.js +285 -0
- package/aws-v3/upload/index.js +157 -0
- package/azure/download/index.js +40 -0
- package/azure/index.js +236 -0
- package/azure/upload/index.js +124 -0
- package/gcp/download/index.js +86 -0
- package/gcp/index.js +801 -0
- package/gcp/upload/index.js +234 -0
- package/ibm/download/index.js +13 -0
- package/ibm/index.js +229 -0
- package/ibm/upload/index.js +13 -0
- package/index.d.ts +6 -0
- package/index.js +832 -0
- package/minio/download/index.js +44 -0
- package/minio/index.js +182 -0
- package/minio/upload/index.js +135 -0
- package/oci/download/index.js +13 -0
- package/oci/index.js +183 -0
- package/oci/upload/index.js +13 -0
- package/package.json +26 -0
- package/types.d.ts +29 -0
- package/util.d.ts +12 -0
- package/util.js +46 -0
package/util.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasBasicAuth = exports.getBasicAuth = exports.formatError = exports.generateFilename = exports.readableAsBuffer = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const util_1 = require("../db/util");
|
|
7
|
+
Object.defineProperty(exports, "getBasicAuth", { enumerable: true, get: function () { return util_1.getBasicAuth; } });
|
|
8
|
+
Object.defineProperty(exports, "hasBasicAuth", { enumerable: true, get: function () { return util_1.hasBasicAuth; } });
|
|
9
|
+
function readableAsBuffer(stream) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
let result = null;
|
|
12
|
+
stream
|
|
13
|
+
.on('data', chunk => {
|
|
14
|
+
result = result ? Buffer.concat([result, chunk]) : chunk;
|
|
15
|
+
})
|
|
16
|
+
.on('end', () => resolve(result))
|
|
17
|
+
.on('error', err => reject(err))
|
|
18
|
+
.read();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
exports.readableAsBuffer = readableAsBuffer;
|
|
22
|
+
function generateFilename(filename) {
|
|
23
|
+
let basename, suffix;
|
|
24
|
+
return (i) => {
|
|
25
|
+
if (i === 1) {
|
|
26
|
+
const j = filename.indexOf('.');
|
|
27
|
+
if (j !== -1) {
|
|
28
|
+
const match = /^([\S\s]+?)_(\d+)$/.exec(basename = filename.substring(0, j));
|
|
29
|
+
if (match) {
|
|
30
|
+
basename = match[1];
|
|
31
|
+
i = parseInt(match[2]) + 1;
|
|
32
|
+
}
|
|
33
|
+
suffix = filename.substring(j);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return basename && suffix ? [basename + `_${i}` + suffix, true] : [(0, types_1.generateUUID)() + path.extname(filename), false];
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
exports.generateFilename = generateFilename;
|
|
40
|
+
function formatError(title, value, hint) {
|
|
41
|
+
if ((0, types_1.isObject)(title)) {
|
|
42
|
+
title = title.service;
|
|
43
|
+
}
|
|
44
|
+
return (0, types_1.errorMessage)(typeof title === 'string' ? title : '', value, hint);
|
|
45
|
+
}
|
|
46
|
+
exports.formatError = formatError;
|