Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
178c360b89 | |||
191e0b8e05 | |||
7d6bbd289d | |||
3f5461dfe0 | |||
78ec895a39 | |||
0b14904027 | |||
a8ce2f75b7 | |||
c383b75336 |
@ -19,23 +19,35 @@ mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
audit:
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
@ -50,9 +62,7 @@ testStable:
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
@ -63,9 +73,7 @@ testBuild:
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
@ -85,6 +93,8 @@ release:
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm"]
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
137
package-lock.json
generated
137
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartbucket",
|
||||
"version": "1.0.33",
|
||||
"version": "1.0.37",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -1445,6 +1445,33 @@
|
||||
"integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==",
|
||||
"dev": true
|
||||
},
|
||||
"@open-wc/dedupe-mixin": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://verdaccio.lossless.one/@open-wc%2fdedupe-mixin/-/dedupe-mixin-1.3.0.tgz",
|
||||
"integrity": "sha512-UfdK1MPnR6T7f3svzzYBfu3qBkkZ/KsPhcpc3JYhsUY4hbpwNF9wEQtD4Z+/mRqMTJrKg++YSxIxE0FBhY3RIw==",
|
||||
"dev": true
|
||||
},
|
||||
"@open-wc/scoped-elements": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://verdaccio.lossless.one/@open-wc%2fscoped-elements/-/scoped-elements-1.3.3.tgz",
|
||||
"integrity": "sha512-vFIQVYYjFw67odUE4JzZOpctnF7S/2DX+S+clrL3bQPql7HvEnV0wMFwOWUavQTuCJi0rfU8GTcNMiUybio+Yg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@open-wc/dedupe-mixin": "^1.3.0",
|
||||
"lit-html": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"@open-wc/testing-helpers": {
|
||||
"version": "1.8.12",
|
||||
"resolved": "https://verdaccio.lossless.one/@open-wc%2ftesting-helpers/-/testing-helpers-1.8.12.tgz",
|
||||
"integrity": "sha512-+4exEHYvnFqI1RGDDIKFHPZ7Ws5NK1epvEku3zLaOYN3zc+huX19SndNc5+X++v8A+quN/iXbHlh80ROyNaYDA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@open-wc/scoped-elements": "^1.2.4",
|
||||
"lit-element": "^2.2.1",
|
||||
"lit-html": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"@parcel/fs": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://verdaccio.lossless.one/@parcel%2ffs/-/fs-1.11.0.tgz",
|
||||
@ -2045,9 +2072,9 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartpromise": {
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz",
|
||||
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg=="
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.1.3.tgz",
|
||||
"integrity": "sha512-KENdm++8uuzxDz1cbUbXtz6InfReP28TYC5zxRgRtwsXh7ZWUkSA+/82IbO97PcSCAfIpg7dwj77G6KGSsTKEQ=="
|
||||
},
|
||||
"@pushrocks/smartpuppeteer": {
|
||||
"version": "1.0.15",
|
||||
@ -2163,16 +2190,43 @@
|
||||
}
|
||||
},
|
||||
"@pushrocks/tapbundle": {
|
||||
"version": "3.2.9",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.2.9.tgz",
|
||||
"integrity": "sha512-vtmYL/l7BZvAzySh7cYnnTG6CFMp5zYtowJuMAmqUjhIaQaWW1Tvbrpjp7lVwRXj2JlL/i69KcJ6RVdLItK+rA==",
|
||||
"version": "3.2.14",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftapbundle/-/tapbundle-3.2.14.tgz",
|
||||
"integrity": "sha512-Hu7SHFww6i17mZ3F8orvzXV7B8nPBRY6PB2Lw2sRfq9+ZbrvUvz7qmbc7d7mXkTGcLx7/7wbH3NHo1V5mplMCQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartdelay": "^2.0.9",
|
||||
"@pushrocks/smartenv": "^4.0.10",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"@pushrocks/smarttime": "^3.0.19",
|
||||
"@open-wc/testing-helpers": "^1.8.12",
|
||||
"@pushrocks/smartdelay": "^2.0.10",
|
||||
"@pushrocks/smartenv": "^4.0.16",
|
||||
"@pushrocks/smartpromise": "^3.1.3",
|
||||
"@pushrocks/smarttime": "^3.0.38",
|
||||
"smartchai": "^2.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartenv": {
|
||||
"version": "4.0.16",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartenv/-/smartenv-4.0.16.tgz",
|
||||
"integrity": "sha512-NwYMONDc/NjY6BGvzZzLMteF83kPQTF9BCGfqWbktUUruEtdqL+nGw6ecoLFi2b5u7XPb8jK1TKIcSvpNJ7SyA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
"@types/node": "^14.11.2"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smarttime": {
|
||||
"version": "3.0.38",
|
||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmarttime/-/smarttime-3.0.38.tgz",
|
||||
"integrity": "sha512-oVT48eZE66OTmDALAsWkk3GXUQiqzkei7mo526UbuMN2iLY8I9WgsxmLfa8Fp4llQmocncW3WTqGyhnEOAuDgA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/lik": "^4.0.17",
|
||||
"@pushrocks/smartdelay": "^2.0.10",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"croner": "^1.1.23",
|
||||
"dayjs": "^1.9.1",
|
||||
"is-nan": "^1.3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@pushrocks/webrequest": {
|
||||
@ -2305,9 +2359,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/chai": {
|
||||
"version": "4.2.13",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.13.tgz",
|
||||
"integrity": "sha512-o3SGYRlOpvLFpwJA6Sl1UPOwKFEvE4FxTEB/c9XHI2whdnd4kmPVkNLL8gY4vWGBxWWDumzLbKsAhEH5SKn37Q==",
|
||||
"version": "4.2.16",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.16.tgz",
|
||||
"integrity": "sha512-vI5iOAsez9+roLS3M3+Xx7w+WRuDtSmF8bQkrbcIJ2sC1PcDgVoA0WGpa+bIrJ+y8zqY2oi//fUctkxtIcXJCw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/chai-as-promised": {
|
||||
@ -2482,9 +2536,9 @@
|
||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
|
||||
},
|
||||
"@types/minio": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fminio/-/minio-7.0.6.tgz",
|
||||
"integrity": "sha512-wSNdxcqse8pHdsIyZcSIbgqZq3qcgdLsvSzp1ZvuxzBb717s7/BvEORiRgkl9r/QDORpoaQGg9vsl387tVtjIA==",
|
||||
"version": "7.0.7",
|
||||
"resolved": "https://verdaccio.lossless.one/@types%2fminio/-/minio-7.0.7.tgz",
|
||||
"integrity": "sha512-cK0VuWZ5zvFmkxQzK46RtJ4qt2Gtrv34hsXDr0D3vqesjrnEKT+0rw0zWk40JtCPkoEFgLdIUbXnePsKjbb80Q==",
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
@ -3075,9 +3129,9 @@
|
||||
}
|
||||
},
|
||||
"block-stream2": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/block-stream2/-/block-stream2-2.0.0.tgz",
|
||||
"integrity": "sha512-1oI+RHHUEo64xomy1ozLgVJetFlHkIfQfJzTBQrj6xWnEMEPooeo2fZoqFjp0yzfHMBrgxwgh70tKp6T17+i3g==",
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://verdaccio.lossless.one/block-stream2/-/block-stream2-2.1.0.tgz",
|
||||
"integrity": "sha512-suhjmLI57Ewpmq00qaygS8UgEq2ly2PCItenIyhMqVjo4t4pGzqMvfgJuX8iWTeSDdfSSqS6j38fL4ToNL7Pfg==",
|
||||
"requires": {
|
||||
"readable-stream": "^3.4.0"
|
||||
}
|
||||
@ -3535,16 +3589,16 @@
|
||||
"dev": true
|
||||
},
|
||||
"chai": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://verdaccio.lossless.one/chai/-/chai-4.2.0.tgz",
|
||||
"integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==",
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://verdaccio.lossless.one/chai/-/chai-4.3.4.tgz",
|
||||
"integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"assertion-error": "^1.1.0",
|
||||
"check-error": "^1.0.2",
|
||||
"deep-eql": "^3.0.1",
|
||||
"get-func-name": "^2.0.0",
|
||||
"pathval": "^1.1.0",
|
||||
"pathval": "^1.1.1",
|
||||
"type-detect": "^4.0.5"
|
||||
}
|
||||
},
|
||||
@ -5365,6 +5419,11 @@
|
||||
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
|
||||
"dev": true
|
||||
},
|
||||
"fast-xml-parser": {
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://verdaccio.lossless.one/fast-xml-parser/-/fast-xml-parser-3.19.0.tgz",
|
||||
"integrity": "sha512-4pXwmBplsCPv8FOY1WRakF970TjNGnGnfbOnLqjlYvMiF1SR3yOHyxMR/YCXpPTOspNF5gwudqktIP4VsWkvBg=="
|
||||
},
|
||||
"fastparse": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://verdaccio.lossless.one/fastparse/-/fastparse-1.1.2.tgz",
|
||||
@ -7267,6 +7326,21 @@
|
||||
"type-check": "~0.3.2"
|
||||
}
|
||||
},
|
||||
"lit-element": {
|
||||
"version": "2.4.0",
|
||||
"resolved": "https://verdaccio.lossless.one/lit-element/-/lit-element-2.4.0.tgz",
|
||||
"integrity": "sha512-pBGLglxyhq/Prk2H91nA0KByq/hx/wssJBQFiYqXhGDvEnY31PRGYf1RglVzyLeRysu0IHm2K0P196uLLWmwFg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lit-html": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"lit-html": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://verdaccio.lossless.one/lit-html/-/lit-html-1.3.0.tgz",
|
||||
"integrity": "sha512-0Q1bwmaFH9O14vycPHw8C/IeHMk/uSDldVLIefu/kfbTBGIc44KGH6A8p1bDfxUfHdc8q6Ct7kQklWoHgr4t1Q==",
|
||||
"dev": true
|
||||
},
|
||||
"locate-path": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://verdaccio.lossless.one/locate-path/-/locate-path-5.0.0.tgz",
|
||||
@ -7627,15 +7701,16 @@
|
||||
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
|
||||
},
|
||||
"minio": {
|
||||
"version": "7.0.16",
|
||||
"resolved": "https://verdaccio.lossless.one/minio/-/minio-7.0.16.tgz",
|
||||
"integrity": "sha512-OgCJ3XVMzukSqoMFBiBDeyz30BxYTBM9yRLVRBCExTb+QKVxJh4DnUOS2/zw7OPeDyXXEvYSzDvg4FkCf1Cxyw==",
|
||||
"version": "7.0.18",
|
||||
"resolved": "https://verdaccio.lossless.one/minio/-/minio-7.0.18.tgz",
|
||||
"integrity": "sha512-jVRjkw8A5Spf+ETY5OXQUcQckHriuUA3u2+MAcX36btLT8EytlOVivxIseXvyFf9cNn3dy5w1F1UyjMvHU+nqg==",
|
||||
"requires": {
|
||||
"async": "^3.1.0",
|
||||
"block-stream2": "^2.0.0",
|
||||
"es6-error": "^4.1.1",
|
||||
"fast-xml-parser": "^3.17.5",
|
||||
"json-stream": "^1.0.0",
|
||||
"lodash": "^4.14.2",
|
||||
"lodash": "^4.17.20",
|
||||
"mime-types": "^2.1.14",
|
||||
"mkdirp": "^0.5.1",
|
||||
"querystring": "0.2.0",
|
||||
@ -8340,9 +8415,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"pathval": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://verdaccio.lossless.one/pathval/-/pathval-1.1.0.tgz",
|
||||
"integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=",
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://verdaccio.lossless.one/pathval/-/pathval-1.1.1.tgz",
|
||||
"integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"pbkdf2": {
|
||||
|
13
package.json
13
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartbucket",
|
||||
"version": "1.0.33",
|
||||
"version": "1.0.37",
|
||||
"description": "simple cloud independent object storage",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
@ -14,18 +14,18 @@
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tstest": "^1.0.52",
|
||||
"@pushrocks/tapbundle": "^3.2.9",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/qenv": "^4.0.10",
|
||||
"@pushrocks/smartpath": "^4.0.3",
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
"@pushrocks/smartpromise": "^3.1.3",
|
||||
"@pushrocks/smartrx": "^2.0.19",
|
||||
"@pushrocks/streamfunction": "^2.0.1",
|
||||
"@types/minio": "^7.0.6",
|
||||
"minio": "^7.0.16"
|
||||
"@types/minio": "^7.0.7",
|
||||
"minio": "^7.0.18"
|
||||
},
|
||||
"private": false,
|
||||
"files": [
|
||||
@ -39,5 +39,8 @@
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ tap.test('should create a valid smartbucket', async () => {
|
||||
testSmartbucket = new smartbucket.SmartBucket({
|
||||
accessKey: testQenv.getEnvVarOnDemand('S3_KEY'),
|
||||
accessSecret: testQenv.getEnvVarOnDemand('S3_SECRET'),
|
||||
endpoint: 'fra1.digitaloceanspaces.com'
|
||||
endpoint: 'fra1.digitaloceanspaces.com',
|
||||
});
|
||||
});
|
||||
|
||||
@ -79,7 +79,9 @@ tap.test('should correctly build paths for sub directories', async () => {
|
||||
tap.test('should list huge file directory', async () => {
|
||||
const servezoneBucket = await smartbucket.Bucket.getBucketByName(testSmartbucket, 'servezone');
|
||||
const servezoneBaseDirectory = await servezoneBucket.getBaseDirectory();
|
||||
const brandfileDirectory = await servezoneBaseDirectory.getSubDirectoryByName('public/brandfiles');
|
||||
const brandfileDirectory = await servezoneBaseDirectory.getSubDirectoryByName(
|
||||
'public/brandfiles'
|
||||
);
|
||||
const files = await brandfileDirectory.listFiles();
|
||||
const directories = await brandfileDirectory.listDirectories();
|
||||
console.log(files);
|
||||
|
@ -6,7 +6,7 @@ import { Observable } from 'rxjs';
|
||||
export class Bucket {
|
||||
public static async getBucketByName(smartbucketRef: SmartBucket, bucketNameArg: string) {
|
||||
const buckets = await smartbucketRef.minioClient.listBuckets();
|
||||
const foundBucket = buckets.find(bucket => {
|
||||
const foundBucket = buckets.find((bucket) => {
|
||||
return bucket.name === bucketNameArg;
|
||||
});
|
||||
|
||||
@ -20,12 +20,12 @@ export class Bucket {
|
||||
}
|
||||
|
||||
public static async createBucketByName(smartbucketRef: SmartBucket, bucketName: string) {
|
||||
await smartbucketRef.minioClient.makeBucket(bucketName, 'ams3').catch(e => console.log(e));
|
||||
await smartbucketRef.minioClient.makeBucket(bucketName, 'ams3').catch((e) => console.log(e));
|
||||
return new Bucket(smartbucketRef, bucketName);
|
||||
}
|
||||
|
||||
public static async removeBucketByName(smartbucketRef: SmartBucket, bucketName: string) {
|
||||
await smartbucketRef.minioClient.removeBucket(bucketName).catch(e => console.log(e));
|
||||
await smartbucketRef.minioClient.removeBucket(bucketName).catch((e) => console.log(e));
|
||||
}
|
||||
|
||||
public smartbucketRef: SmartBucket;
|
||||
@ -54,7 +54,7 @@ export class Bucket {
|
||||
const streamIntake = new plugins.streamfunction.Intake();
|
||||
const putPromise = this.smartbucketRef.minioClient
|
||||
.putObject(this.name, pathArg, streamIntake.getReadable())
|
||||
.catch(e => console.log(e));
|
||||
.catch((e) => console.log(e));
|
||||
streamIntake.pushData(fileContent);
|
||||
streamIntake.signalEnd();
|
||||
await putPromise;
|
||||
@ -68,12 +68,12 @@ export class Bucket {
|
||||
let completeFile: Buffer;
|
||||
const replaySubject = await this.fastGetStream(pathArg);
|
||||
replaySubject.subscribe(
|
||||
chunk => {
|
||||
(chunk) => {
|
||||
if (completeFile) {
|
||||
completeFile = Buffer.concat([completeFile, chunk]);
|
||||
}
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
console.log(err);
|
||||
},
|
||||
() => {
|
||||
@ -87,15 +87,14 @@ export class Bucket {
|
||||
public async fastGetStream(pathArg: string): Promise<plugins.smartrx.rxjs.ReplaySubject<Buffer>> {
|
||||
const fileStream = await this.smartbucketRef.minioClient
|
||||
.getObject(this.name, pathArg)
|
||||
.catch(e => console.log(e));
|
||||
.catch((e) => console.log(e));
|
||||
const replaySubject = new plugins.smartrx.rxjs.ReplaySubject<Buffer>();
|
||||
const duplexStream = plugins.streamfunction.createDuplexStream<Buffer, Buffer>(
|
||||
async chunk => {
|
||||
async (chunk) => {
|
||||
replaySubject.next(chunk);
|
||||
return chunk;
|
||||
},
|
||||
async cb => {
|
||||
console.log('stream ended');
|
||||
async (cb) => {
|
||||
replaySubject.complete();
|
||||
return Buffer.from('');
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ export class Directory {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
console.log(basePath);
|
||||
return basePath;
|
||||
}
|
||||
|
||||
@ -72,7 +71,7 @@ export class Directory {
|
||||
);
|
||||
const fileArray: File[] = [];
|
||||
const duplexStream = plugins.streamfunction.createDuplexStream<plugins.minio.BucketItem, void>(
|
||||
async bucketItem => {
|
||||
async (bucketItem) => {
|
||||
if (bucketItem.prefix) {
|
||||
return;
|
||||
}
|
||||
@ -87,7 +86,7 @@ export class Directory {
|
||||
fileArray.push(new File(this, subtractedPath));
|
||||
}
|
||||
},
|
||||
async tools => {
|
||||
async (tools) => {
|
||||
done.resolve();
|
||||
}
|
||||
);
|
||||
@ -109,7 +108,7 @@ export class Directory {
|
||||
);
|
||||
const directoryArray: Directory[] = [];
|
||||
const duplexStream = plugins.streamfunction.createDuplexStream<plugins.minio.BucketItem, void>(
|
||||
async bucketItem => {
|
||||
async (bucketItem) => {
|
||||
if (bucketItem.name) {
|
||||
return;
|
||||
}
|
||||
@ -119,13 +118,13 @@ export class Directory {
|
||||
}
|
||||
if (subtractedPath.includes('/')) {
|
||||
const dirName = subtractedPath.split('/')[0];
|
||||
if (directoryArray.find(directory => directory.name === dirName)) {
|
||||
if (directoryArray.find((directory) => directory.name === dirName)) {
|
||||
return;
|
||||
}
|
||||
directoryArray.push(new Directory(this.bucketRef, this, dirName));
|
||||
}
|
||||
},
|
||||
async tools => {
|
||||
async (tools) => {
|
||||
done.resolve();
|
||||
}
|
||||
);
|
||||
@ -153,7 +152,7 @@ export class Directory {
|
||||
|
||||
const getDirectory = async (directoryArg: Directory, dirNameToSearch: string) => {
|
||||
const directories = await directoryArg.listDirectories();
|
||||
return directories.find(directory => {
|
||||
return directories.find((directory) => {
|
||||
return directory.name === dirNameToSearch;
|
||||
});
|
||||
};
|
||||
@ -202,4 +201,25 @@ export class Directory {
|
||||
const path = plugins.path.join(this.getBasePath(), pathArg);
|
||||
await this.bucketRef.fastRemove(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes the directory with all its contents
|
||||
*/
|
||||
public async deleteWithAllContents() {
|
||||
const deleteDirectory = async (directoryArg: Directory) => {
|
||||
const childDirectories = await directoryArg.listDirectories();
|
||||
if (childDirectories.length === 0) {
|
||||
console.log('directory empty! Path complete!');
|
||||
} else {
|
||||
for (const childDir of childDirectories) {
|
||||
await deleteDirectory(childDir);
|
||||
}
|
||||
}
|
||||
const files = await directoryArg.listFiles();
|
||||
for (const file of files) {
|
||||
await directoryArg.fastRemove(file.name);
|
||||
}
|
||||
};
|
||||
await deleteDirectory(this);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ export class File {
|
||||
const streamIntake = new plugins.streamfunction.Intake();
|
||||
const putPromise = directoryRef.bucketRef.smartbucketRef.minioClient
|
||||
.putObject(this.name, filePath, streamIntake.getReadable())
|
||||
.catch(e => console.log(e));
|
||||
.catch((e) => console.log(e));
|
||||
streamIntake.pushData(fileContent);
|
||||
streamIntake.signalEnd();
|
||||
await putPromise;
|
||||
@ -53,14 +53,14 @@ export class File {
|
||||
const done = plugins.smartpromise.defer();
|
||||
const fileStream = await this.parentDirectoryRef.bucketRef.smartbucketRef.minioClient
|
||||
.getObject(this.parentDirectoryRef.bucketRef.name, this.path)
|
||||
.catch(e => console.log(e));
|
||||
.catch((e) => console.log(e));
|
||||
let completeFile = new Buffer('');
|
||||
const duplexStream = plugins.streamfunction.createDuplexStream<Buffer, Buffer>(
|
||||
async chunk => {
|
||||
async (chunk) => {
|
||||
completeFile = Buffer.concat([chunk]);
|
||||
return chunk;
|
||||
},
|
||||
async cb => {
|
||||
async (cb) => {
|
||||
done.resolve();
|
||||
return Buffer.from('');
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export class SmartBucket {
|
||||
port: 443,
|
||||
useSSL: true,
|
||||
accessKey: this.config.accessKey,
|
||||
secretKey: this.config.accessSecret
|
||||
secretKey: this.config.accessSecret,
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user