@not3/sdk
    Preparing search index...

    Class FileUpload

    The FileUpload class is a helper to split files into chunks, encrypt them, and upload them to the server.

    Index

    Constructors

    • Create an managed FileUpload object

      Parameters

      • api: FilesAPI

        The FilesAPI instance to use

      • name: string

        The name of the file being uploaded

      • size: number

        The size of the file being uploaded in bytes

      • parallelUploads: number = 1

        The amount of parallel uploads to use, do not set this too high, or you risk getting rate limited

      • cancelOnError: boolean = true

        Should the upload be cancelled if an error occurs?

      • seed: string = ...

        The seed to use for encryption, if not provided, a random seed will be generated

      Returns FileUpload

    Properties

    ACTUAL_CHUNK_SIZE: number = ...

    The size of each chunk to upload, minus the AES header size.

    CHUNK_SIZE - Crypto.AES_CBC_HEADER_BYTES
    
    CHUNK_SIZE: number = ...

    The size of each chunk to upload.

    1024 * 1024 * 5
    

    Methods

    • Cancel the upload. This action is not immediate, and could take a few moments to complete. The reason behind this is that wee need to wait for the threads to finish their current task, before they check if they should cancel.

      Returns Promise<void>

      A promise that resolves when the cancellation request is sent

    • Get the amount of chunks this file will be split into

      Returns number

      The amount of chunks

    • Get the size of the file after encryption

      Returns number

      The size of the file after encryption

    • Get the seed used for encryption. Needed for decryption.

      Returns string

      The seed, handle with care.

    • Is the upload finished?

      Returns boolean

      True if the upload is finished

    • Is the upload started?

      Returns boolean

      True if the upload is started

    • If the current upload is crashed, or you want to resume another upload, you can use this method.

      Parameters

      • getBytes: GetBytesFn

        The function to get bytes from the file

      • Optionalopt: { id?: string; progress?: FileUploadProgress }

        Options for the resume operation

      Returns Promise<void>

      A promise that resolves when the upload is completed

    • Start the upload process.

      Parameters

      • getBytes: GetBytesFn

        The function to get bytes from the file

      Returns Promise<void>

      A promise that resolves when the upload is completed