edgekitjs - v0.0.51
    Preparing search index...

    Class FS

    Upload, store and serve images, videos, music, documents and other unstructured data in your Edge-first application.

    Hierarchy

    • R2FileStorage
      • FS
    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    • Parameters

      • r2: R2Bucket

        The R2Bucket bindings to use

      Returns FS

    Properties

    r2: R2Bucket

    Accessors

    Methods

    • Returns the file with the given key, or null if no such key exists.

      Parameters

      • key: string

      Returns Promise<null | File>

    • Returns true if a file with the given key exists, false otherwise.

      Parameters

      • key: string

      Returns Promise<boolean>

    • Type Parameters

      • T extends ListOptions

      Parameters

      • Optionaloptions: T

      Returns Promise<ListResult<T>>

    • Parameters

      • key: string
      • file: File

      Returns Promise<File>

    • Removes the file with the given key from storage.

      Parameters

      • key: string

      Returns Promise<void>

    • Returns a Response with the file body and correct headers. If the file doesn't exits it returns a 404 response with an empty body.

      Parameters

      • key: string

        The key of the file to serve

      • init: Init = {}

        The response init object, with an optional fallback body

      Returns Promise<Response>

    • Puts a file in storage at the given key.

      Parameters

      • key: string
      • file: File

      Returns Promise<void>

    • Create a new FileUploadHandler function that will automatically upload files to the File Storage.

      The handle will only upload files if they match a list of valid input field name. The key used to store the file can be customized with a getKey function.

      Parameters

      • allowedFieldNames: AllowedFieldNames

        The form field names allowed to upload files.

      • OptionalgetKey: GetKeyFunction

        A function that returns the key usd to store the file in the file system.

      Returns FileUploadHandler

      A file upload handler function that can be used with the parseFormData.