Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
aws-api-read-stream
Advanced tools
Turn an aws api call into a readable stream.
npm i aws-api-read-stream
Piping the result of s3.listObjectsV2()
Take care to use NextToken
or ContinuationToken
accordingly.
const aws = require('aws-sdk')
const APIStream = require('aws-api-read-stream')
const { promisify } = require('util')
const pipeline = promisify(require('stream').pipeline)
async function main() {
const s3 = new aws.S3()
const s = APIStream.from((nextToken) => {
return s3.listObjectsV2({
Bucket: 'your-bucket-here',
ContinuationToken: nextToken
}).promise()
})
// convert the object stream to strings using async generator
// (node 13.* and above)
const transform = async function*(source) {
for await (const chunk of source) {
yield JSON.stringify(chunk)
}
}
await pipeline(s, transform, process.stdout)
}
main()
Keep reading until the stream finishes. This will buffer the results in an internal array, be wary though, because this might crash the process if it runs out of memory
const aws = require('aws-sdk')
const APIStream = require('aws-api-read-stream')
const { promisify } = require('util')
const pipeline = promisify(require('stream').pipeline)
async function main() {
const s3 = new aws.S3()
const s = APIStream.from((nextToken) => {
return s3.listObjectsV2({
Bucket: 'your-bucket-here',
ContinuationToken: nextToken
}).promise()
})
const results = await s.readAll()
}
main()
Provide Readable
stream options during initialization.
objectMode
will always be set to true
const s = APIStream.from((nextToken) => {
return s3.listObjectsV2({
Bucket: 'your-bucket-here',
ContinuationToken: nextToken
}).promise()
}, { options: { ... your options here } })
Start with an existing nextToken
const s = APIStream.from((nextToken) => {
return s3.listObjectsV2({
Bucket: 'your-bucket-here',
ContinuationToken: nextToken
}).promise()
}, { nextToken: '123123' })
FAQs
turns an aws api call into a readable stream
The npm package aws-api-read-stream receives a total of 0 weekly downloads. As such, aws-api-read-stream popularity was classified as not popular.
We found that aws-api-read-stream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.