public/helper/Send-TwitterMedia_Upload_Append.ps1

function Send-TwitterMedia_Upload_Append {

<#
.SYNOPSIS
    Upload media
 
.DESCRIPTION
    POST media/upload (APPEND)
     
    Overview
     
    The APPEND command is used to upload a chunk (consecutive byte range) of the media file. For example, a 3 MB file could be split into 3 chunks of size 1 MB, and uploaded using 3 APPEND command requests. After the entire file is uploaded, the next step is to call the FINALIZE command.
     
    There are a number of advantages of uploading a media file in small chunks:
     
    Improved reliability and success rates under low bandwidth network conditions
    Uploads can be paused and resumed
    File chunks can be retried individually
    Ability to tune chunk sizes to match changing network conditions e.g on cellular clients
     
    Request
     
    Requests should be multipart/form-data POST format.
     
    Note: The domain for this endpoint is upload.twitter.com
     
    Response
     
    A successful response returns HTTP 2xx.
 
.PARAMETER command
    Must be set to APPEND (case sensitive).
 
.PARAMETER media_id
    The media_id returned from the INIT command.
 
.PARAMETER media
    The raw binary file content being uploaded. It must be <= 5 MB, and cannot be used with media_data.
 
.PARAMETER media_data
    The base64-encoded chunk of media file. It must be <= 5 MB and cannot be used with media. Use raw binary (media parameter) when possible.
 
.PARAMETER segment_index
    An ordered index of file chunk. It must be between 0-999 inclusive. The first segment has index 0, second segment has index 1, and so on.
 
.NOTES
    This helper function was generated by the information provided here:
    https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload-append
 
#>

    [CmdletBinding()]
    Param(
        [string]$command,
        [string]$media_id,
        [string]$media,
        [string]$media_data,
        [string]$segment_index
    )
    Begin {

        [string]$Method      = 'POST'
        [string]$Resource    = '/media/upload'
        [string]$ResourceUrl = 'https://upload.twitter.com/1.1/media/upload.json'

        [hashtable]$Parameters = $PSBoundParameters
                   $CmdletBindingParameters | ForEach-Object { $Parameters.Remove($_) }

    }
    Process {

        If (-Not $OAuthSettings) { $OAuthSettings = Get-TwitterOAuthSettings -Resource $Resource }
        Invoke-TwitterAPI -Method $Method -ResourceUrl $ResourceUrl -Resource $Resource -Parameters $Parameters -OAuthSettings $OAuthSettings

    }
    End {

    }
}