@theshelf/filestore 0.3.1 → 0.3.2
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/drivers/S3.js +14 -7
- package/package.json +1 -1
package/dist/drivers/S3.js
CHANGED
|
@@ -18,23 +18,30 @@ export default class S3 {
|
|
|
18
18
|
this.#client = new S3Client(this.#configuration);
|
|
19
19
|
const buckets = await this.#client.send(new ListBucketsCommand({}));
|
|
20
20
|
const bucketExists = buckets.Buckets?.some(bucket => bucket.Name === this.#bucketName);
|
|
21
|
-
if (bucketExists
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (bucketExists !== true) {
|
|
22
|
+
const createBucket = new CreateBucketCommand({ Bucket: this.#bucketName });
|
|
23
|
+
await this.#client.send(createBucket);
|
|
24
|
+
}
|
|
25
|
+
this.#connected = true;
|
|
24
26
|
}
|
|
25
27
|
catch (error) {
|
|
26
28
|
const message = error instanceof Error ? error.message : UNKNOWN_ERROR;
|
|
27
29
|
throw new FileStoreError('File store connection failed: ' + message);
|
|
28
30
|
}
|
|
29
|
-
this.#connected = true;
|
|
30
31
|
}
|
|
31
32
|
async disconnect() {
|
|
32
33
|
if (this.#client === undefined) {
|
|
33
34
|
throw new NotConnected();
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
try {
|
|
37
|
+
this.#client.destroy();
|
|
38
|
+
this.#client = undefined;
|
|
39
|
+
this.#connected = false;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
const message = error instanceof Error ? error.message : UNKNOWN_ERROR;
|
|
43
|
+
throw new FileStoreError('File store disconnection failed: ' + message);
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
46
|
async hasFile(path) {
|
|
40
47
|
const client = this.#getClient();
|