@ludovicm67/lib-filetransfer
    Preparing search index...

    Class TransferFile

    Index

    Constructors

    • Generate a new TransferFile instance.

      Parameters

      • id: string

        Id of the file.

      • name: string

        Name of the file.

      • type: string

        Type of the file.

      • size: number

        Size of the file.

      • bufferLength: number

        Length of the internal buffer.

      • Optionaltimeout: number

        Timeout for a single check in seconds.

      • Optionalretries: number

        Number of retries before considering it as a failure.

      Returns TransferFile

    Methods

    • Clear the content of the file. The user will need to download it again.

      Returns void

    • Download the file.

      Parameters

      • maxBufferSize: number

        Maximum length for the data to ask at one time.

      • askFilePartCallback: AskFilePartCallback

        Function that will be called to ask for some parts of the file.

      • parallelCalls: number = 1

        Number of parallel calls to perform (default value: 1).

      • Optionaltimeout: number

        Timeout for a single check in seconds.

      • Optionalretries: number

        Number of retries before considering it as a failure.

      Returns Promise<void>

    • Get the Blob of the complete file.

      Returns Blob

      The Blob of the file.

    • Check the presence of a specific part of the file.

      Parameters

      • offset: number

        Offset from the start.

      • limit: number

        The requested limit.

      Returns ArrayBuffer

      true if the part exists or if the file is complete.

    • Check if the file is complete.

      Returns boolean

      true if the file is complete.

    • Check if the file is downloading.

      Returns boolean

      true if the file is downloading.

    • Read limit bytes at maximum from offset from the file.

      Parameters

      • offset: number

        Offset from the start.

      • limit: number

        Maximum number of bytes to return.

      Returns ArrayBuffer

      ArrayBuffer with the requested file part.

    • Receive a part of the file.

      Parameters

      • offset: number

        Offset from the start.

      • limit: number

        The requested limit.

      • data: ArrayBuffer

        ArrayBuffer containing the requested data.

      Returns void

    • Set a Blob as being the content of this file.

      Parameters

      • blob: Blob

      Returns Promise<void>

    • Set the file as being complete.

      Parameters

      • isComplete: boolean = true

        True if the download is complete.

      Returns void

    • Set the file as being downloaded.

      Parameters

      • isDownloading: boolean = true

        True if the file is being downloaded.

      Returns void

    • Set an error message.

      Parameters

      • message: undefined | string

        A relevant error message.

      • isErrored: boolean = true

        True in case of an error.

      Returns void

    • Wait and check for presence of a specific part of the file.

      Parameters

      • offset: number

        Offset from the start.

      • limit: number

        The requested limit.

      • timeout: number = 1

        Timeout in seconds (default: 1)

      Returns Promise<boolean>

      true of the part was received.

    • Wait for a specific part of a file, with some retries.

      Parameters

      • askFilePartCallback: AskFilePartCallback

        Function to ask a file part to the sender.

      • offset: number

        Offset from the start.

      • limit: number

        Maximum number of bytes that we can read.

      • Optionaltimeout: number

        Timeout for a single check in seconds.

      • Optionalretries: number

        Number of retries before considering it as a failure.

      Returns Promise<void>