-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
function New-MultipartFileContent { [OutputType('System.Net.Http.MultipartFormDataContent')] [CmdletBinding()] param( [Parameter(Mandatory)] [System.IO.FileInfo]$File, [string]$HeaderName = 'file' ) #https://github.com/PowerShell/PowerShell/issues/9241#issuecomment-477467675 # build the header and make sure to include quotes around Name # and FileName like https://github.com/PowerShell/PowerShell/pull/6782) $fileHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new('form-data') $fileHeader.Name = "`"$HeaderName`"" $fileHeader.FileName = "`"$($File.Name)`"" # build the content $fs = [System.IO.FileStream]::new($File.FullName, [System.IO.FileMode]::Open) $fileContent = [System.Net.Http.StreamContent]::new($fs) $fileContent.Headers.ContentDisposition = $fileHeader $fileContent.Headers.ContentType = [System.Net.Http.Headers.MediaTypeHeaderValue]::Parse('application/octet-stream') # add it to a new MultipartFormDataContent object $mp = [System.Net.Http.MultipartFormDataContent]::new() $mp.Add($fileContent) # get rid of the quotes around the boundary value # https://github.com/PowerShell/PowerShell/issues/9241 $b = $mp.Headers.ContentType.Parameters | Where-Object { $_.Name -eq 'boundary' } $b.Value = $b.Value.Trim('"') # return an array wrapped copy of the object to avoid PowerShell unrolling return @(, $mp) }
Related posts
-
3 lines of code don't understand the results.
-
Task Scheduler -windowstyle hidden / minimized
-
Just messing around with arrays and efficiency in PS, thought I'd share
-
Register-ArgumentCompleter: how to fall back to file completion when completing a flag such as "--foo="
-
New PowerShell Version - v7.3.7: [7.3.7] - 2023-09-18