Skip to content

Commit

Permalink
update as per review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
prakashsvmx committed Dec 19, 2023
1 parent fdc27c8 commit 7b9178b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ const selectOpts = {
requestProgress: { Enabled: true },
}

const res = minioClient.selectObjectContent('bucketName', 'objectName', selectOpts)
const res = await minioClient.selectObjectContent('bucketName', 'objectName', selectOpts)
console.log(res)
```

Expand Down
5 changes: 2 additions & 3 deletions src/internal/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2145,8 +2145,7 @@ export class TypedClient {
}

const method = 'POST'
let query = `select`
query += '&select-type=2'
const query = `select&select-type=2`

const config: Record<string, unknown>[] = [
{
Expand Down Expand Up @@ -2179,7 +2178,7 @@ export class TypedClient {
})
const payload = builder.buildObject(config)

const res = await this.makeRequestAsync({ method, bucketName, objectName, query }, payload, [200], '')
const res = await this.makeRequestAsync({ method, bucketName, objectName, query }, payload)
const body = await readAsBuffer(res)
return parseSelectObjectContentResponse(body)
}
Expand Down
33 changes: 17 additions & 16 deletions src/internal/xml-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,20 +398,21 @@ export function parseBucketVersioningConfig(xml: string) {
return xmlObj.VersioningConfiguration
}

export function parseSelectObjectContentResponse(res: Buffer) {
// extractHeaderType extracts the first half of the header message, the header type.
function extractHeaderType(stream: stream.Readable): string | undefined {
const headerNameLen = Buffer.from(stream.read(1)).readUInt8()
const headerNameWithSeparator = Buffer.from(stream.read(headerNameLen)).toString()
const splitBySeparator = (headerNameWithSeparator || '').split(':')
return splitBySeparator.length >= 1 ? splitBySeparator[1] : ''
}
// Used only in selectObectContent API.
// extractHeaderType extracts the first half of the header message, the header type.
function extractHeaderType(stream: stream.Readable): string | undefined {
const headerNameLen = Buffer.from(stream.read(1)).readUInt8()
const headerNameWithSeparator = Buffer.from(stream.read(headerNameLen)).toString()
const splitBySeparator = (headerNameWithSeparator || '').split(':')
return splitBySeparator.length >= 1 ? splitBySeparator[1] : ''
}

function extractHeaderValue(stream: stream.Readable) {
const bodyLen = Buffer.from(stream.read(2)).readUInt16BE()
return Buffer.from(stream.read(bodyLen)).toString()
}
function extractHeaderValue(stream: stream.Readable) {
const bodyLen = Buffer.from(stream.read(2)).readUInt16BE()
return Buffer.from(stream.read(bodyLen)).toString()
}

export function parseSelectObjectContentResponse(res: Buffer) {
const selectResults = new SelectResults({}) // will be returned

const responseStream = readableStream(res) // convert byte array to a readable responseStream
Expand Down Expand Up @@ -533,8 +534,8 @@ export function parseSelectObjectContentResponse(res: Buffer) {
// eslint-disable-next-line no-console
console.warn(warningMessage)
}
} // eventType End
} // Event End
} // messageType End
} // Top Level Stream End
}
}
}
}
}

0 comments on commit 7b9178b

Please sign in to comment.