Node.js - bucket.file.getUploadUrl()

Create an upload URL for a file within a bucket.

import { bucket } from '@nitric/sdk'

const assets = bucket('assets').allow('read', 'write')

const logo = assets.file('images/logo.png')

// Create a read-only signed url reference for uploading
const uploadUrl = await logo.getUploadUrl()

Parameters

  • Name
    options
    Optional
    Optional
    Type
    SignUrlOptions
    Description

    Additional options when creating a signed URL.

    • Name
      expiry
      Optional
      Optional
      Type
      number
      Description

      Seconds until link expiry. Defaults to 600, Maximum of 604800 (7 days).

Examples

Create a temporary file upload link for a user

import { bucket } from '@nitric/sdk'

const uploads = bucket('uploads').allow('write')

const photo = uploads.file('images/photo.png')

const photoUrl = await photo.getUploadUrl({
  expiry: 300,
})