Node.js - bucket.file.read()

This is reference documentation for the Nitric Node.js SDK. To learn about Buckets and Storage in Nitric start with the Storage docs.

Read the contents of a file from a bucket.

import { bucket } from '@nitric/sdk'
const assets = bucket('assets').allow('read')
const logo = assets.file('images/logo.png')
const logoData = await logo.read()

Examples

Read a file

import { bucket } from '@nitric/sdk'
const assets = bucket('assets').allow('read')
const logo = assets.file('images/logo.png')
try {
const logoData = await logo.read()
console.log('Logo data:', logoData)
} catch (error) {
console.error('Error reading logo:', error)
}
Last updated on Apr 2, 2025