Python - bucket.file.write()

Write a file to a bucket.

from nitric.resources import bucket
from nitric.application import Nitric
assets = bucket('assets').allow('read')
logo = assets.file('images/logo.png')
logo_data = await logo.write(some_data)
Nitric.run()

Earlier versions of the Nitric SDK used 'reading'. The latest version uses 'read'.

Parameters

  • Name
    data
    Required
    Required
    Type
    bytes
    Description

    The data to write to the file.

Examples

Write a file

from nitric.resources import bucket
from nitric.application import Nitric
# Create a reference to an 'assets' bucket with write permissions
assets = bucket('assets').allow('write')
logo = assets.file('images/logo.png')
logo_data = await logo.write(some_data)
Nitric.run()

Earlier versions of the Nitric SDK used 'writing'. The latest version uses 'write'.

Last updated on Oct 22, 2024