streamby-core 0.9.14 → 0.9.16

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.
@@ -18,8 +18,8 @@ function createS3Adapter(config) {
18
18
  return {
19
19
  async getPresignedUrl(filename, contentType, projectId) {
20
20
  const salt = await bcrypt_1.default.genSalt();
21
- const hashedPassword = await bcrypt_1.default.hash(filename, salt);
22
- const key = `${projectId}/${contentType}/file-${Date.now()}-${hashedPassword}`;
21
+ const hashed = await bcrypt_1.default.hash(filename, salt);
22
+ const key = `${projectId}/${contentType}/file-${Date.now()}-${hashed.replace(/\//g, '-')}`;
23
23
  const command = new client_s3_1.PutObjectCommand({
24
24
  Bucket: config.bucket,
25
25
  Key: key,
@@ -38,20 +38,30 @@ function createS3Adapter(config) {
38
38
  return result.Contents || [];
39
39
  },
40
40
  async deleteProjectDirectory(projectId) {
41
- const listCommand = new client_s3_1.ListObjectsV2Command({
42
- Bucket: config.bucket,
43
- Prefix: `${projectId}/`,
44
- });
45
- const listedObjects = await s3.send(listCommand);
46
- if (!listedObjects.Contents || listedObjects.Contents.length === 0)
47
- return;
48
- const deleteCommand = new client_s3_1.DeleteObjectsCommand({
49
- Bucket: config.bucket,
50
- Delete: {
51
- Objects: listedObjects.Contents.map((item) => ({ Key: item.Key })),
52
- },
53
- });
54
- await s3.send(deleteCommand);
55
- },
41
+ const prefix = `${projectId}/`;
42
+ let continuationToken = undefined;
43
+ while (true) {
44
+ const listCommand = new client_s3_1.ListObjectsV2Command({
45
+ Bucket: config.bucket,
46
+ Prefix: prefix,
47
+ ContinuationToken: continuationToken
48
+ });
49
+ const listedObjects = await s3.send(listCommand);
50
+ const contents = listedObjects.Contents || [];
51
+ if (contents.length > 0) {
52
+ const objectsToDelete = contents.map((item) => ({
53
+ Key: item.Key
54
+ }));
55
+ const deleteCommand = new client_s3_1.DeleteObjectsCommand({
56
+ Bucket: config.bucket,
57
+ Delete: { Objects: objectsToDelete },
58
+ });
59
+ await s3.send(deleteCommand);
60
+ }
61
+ if (!listedObjects.IsTruncated)
62
+ break;
63
+ continuationToken = listedObjects.NextContinuationToken;
64
+ }
65
+ }
56
66
  };
57
67
  }
@@ -10,7 +10,7 @@ export type StorageProviderType = 's3';
10
10
  export interface StorageAdapter {
11
11
  listFiles(projectId: string): Promise<any[]>;
12
12
  getPresignedUrl?: (filename: string, contentType: string, projectId: string) => Promise<any>;
13
- deleteProjectDirectory: (projectId: string) => Promise<void>;
13
+ deleteProjectDirectory: (projectId: string) => Promise<any>;
14
14
  }
15
15
  export interface ProjectInfo {
16
16
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamby-core",
3
- "version": "0.9.14",
3
+ "version": "0.9.16",
4
4
  "description": "StreamBy middleware framework for media storage management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",