diff --git a/packages/oc-s3-storage-adapter/src/index.ts b/packages/oc-s3-storage-adapter/src/index.ts index 974cb19..49e62d1 100644 --- a/packages/oc-s3-storage-adapter/src/index.ts +++ b/packages/oc-s3-storage-adapter/src/index.ts @@ -123,7 +123,7 @@ export default function s3Adapter(conf: S3Config): StorageAdapter { return streamToString(data.Body as any); } catch (err) { - throw (err as any).code === 'NoSuchKey' + throw (err as any).Code === 'NoSuchKey' ? { code: strings.errors.STORAGE.FILE_NOT_FOUND_CODE, msg: strings.errors.STORAGE.FILE_NOT_FOUND(filePath) @@ -176,7 +176,7 @@ export default function s3Adapter(conf: S3Config): StorageAdapter { Delimiter: '/' }); - if (data.CommonPrefixes!.length === 0) { + if (data.CommonPrefixes === undefined || data.CommonPrefixes.length === 0) { throw { code: strings.errors.STORAGE.DIR_NOT_FOUND_CODE, msg: strings.errors.STORAGE.DIR_NOT_FOUND(dir)