Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion drivers/s3/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
type DeleteObjectCommandInput,
type ListObjectsV2CommandInput,
type DeleteObjectsCommandInput,
type _Object,
} from '@aws-sdk/client-s3'

import debug from './debug.js'
Expand Down Expand Up @@ -82,7 +83,7 @@ export class S3Driver implements DriverContract {
#createFileMetaData(apiFile: HeadObjectOutput) {
const metaData: ObjectMetaData = {
contentType: apiFile.ContentType,
contentLength: apiFile.ContentLength!,
contentLength: apiFile.ContentLength ?? (apiFile as _Object).Size ?? 0,
etag: apiFile.ETag!,
lastModified: new Date(apiFile.LastModified!),
}
Expand Down
8 changes: 8 additions & 0 deletions tests/drivers/s3/list_all.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ test.group('S3 Driver | listAll | root dir', (group) => {
}

const { objects } = await s3fs.listAll('/', { recursive: true })

for (const object of objects) {
if (object.isFile) {
const metadata = await object.getMetaData()
assert.equal(metadata.contentLength, 11)
}
}

assert.includeDeepMembers(Array.from(objects), [
{
isDirectory: false,
Expand Down