feat: 完善安装部署与数字溯源码
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
DeleteObjectCommand,
|
||||
GetObjectCommand,
|
||||
ListObjectsV2Command,
|
||||
PutObjectCommand,
|
||||
S3Client,
|
||||
} from '@aws-sdk/client-s3';
|
||||
@@ -56,6 +57,19 @@ export class OssDriver implements StorageDriver {
|
||||
await this.client.send(new DeleteObjectCommand({ Bucket: this.opts.bucket, Key: key }));
|
||||
}
|
||||
|
||||
async list(): Promise<string[]> {
|
||||
const keys: string[] = [];
|
||||
let token: string | undefined;
|
||||
do {
|
||||
const res = await this.client.send(new ListObjectsV2Command({ Bucket: this.opts.bucket, ContinuationToken: token }));
|
||||
for (const item of res.Contents || []) {
|
||||
if (item.Key) keys.push(item.Key);
|
||||
}
|
||||
token = res.NextContinuationToken;
|
||||
} while (token);
|
||||
return keys;
|
||||
}
|
||||
|
||||
getPublicUrl(key: string): string {
|
||||
if (this.opts.cdnBaseUrl) {
|
||||
return `${this.opts.cdnBaseUrl.replace(/\/$/, '')}/${key}`;
|
||||
|
||||
Reference in New Issue
Block a user