Correction README.md
Ajout modification du fichier Project.gfx
This commit is contained in:
@@ -65,7 +65,9 @@ function Invoke-EnoceanGet {
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[AllowEmptyString()]
|
||||
[string]$Password
|
||||
[string]$Password,
|
||||
|
||||
[switch]$RawBytes
|
||||
)
|
||||
|
||||
$headers = Get-AuthHeader -Username $Username -Password $Password
|
||||
@@ -75,6 +77,14 @@ function Invoke-EnoceanGet {
|
||||
|
||||
$response = Invoke-WebRequest -Uri $url -Method GET -Headers $headers -UseBasicParsing -TimeoutSec 30
|
||||
|
||||
# Retourner les bytes bruts si demande (pour fichiers binaires comme .gfx)
|
||||
if ($RawBytes) {
|
||||
if ($response.Content -is [byte[]]) {
|
||||
return , $response.Content
|
||||
}
|
||||
return , [System.Text.Encoding]::UTF8.GetBytes($response.Content)
|
||||
}
|
||||
|
||||
# Si la reponse est un byte[] (encode=bin), decoder en string UTF-8 sans BOM
|
||||
if ($response.Content -is [byte[]]) {
|
||||
return [System.Text.Encoding]::UTF8.GetString($response.Content).TrimStart([char]0xFEFF)
|
||||
@@ -82,7 +92,7 @@ function Invoke-EnoceanGet {
|
||||
return $response.Content
|
||||
}
|
||||
|
||||
function Send-EnoceanConfig {
|
||||
function Send-MultipartFile {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -92,10 +102,13 @@ function Send-EnoceanConfig {
|
||||
[string]$ApiBasePath,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[byte[]]$ZipBytes,
|
||||
[string]$ResourcePath,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[string]$ZipFilename,
|
||||
[byte[]]$FileBytes,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Filename,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Username,
|
||||
@@ -106,17 +119,15 @@ function Send-EnoceanConfig {
|
||||
)
|
||||
|
||||
$authHeaders = Get-AuthHeader -Username $Username -Password $Password
|
||||
$url = "$BaseUrl$ApiBasePath/files/bacnet/inputConfiguration"
|
||||
$url = "$BaseUrl$ApiBasePath/$($ResourcePath.TrimStart('/'))"
|
||||
|
||||
Write-Log -Message "POST $url (fichier: $ZipFilename, taille: $($ZipBytes.Length) octets)" -Level INFO
|
||||
Write-Log -Message "POST $url (fichier: $Filename, taille: $($FileBytes.Length) octets)" -Level INFO
|
||||
|
||||
# Construction multipart manuelle
|
||||
$boundary = [System.Guid]::NewGuid().ToString("N")
|
||||
$encoding = [System.Text.Encoding]::ASCII
|
||||
|
||||
# Partie avant le fichier
|
||||
$headerPart = "--$boundary`r`nContent-Disposition: form-data; name=`"File`"; filename=`"$ZipFilename`"`r`nContent-Type: application/octet-stream`r`n`r`n"
|
||||
# Partie finale
|
||||
$headerPart = "--$boundary`r`nContent-Disposition: form-data; name=`"File`"; filename=`"$Filename`"`r`nContent-Type: application/octet-stream`r`n`r`n"
|
||||
$footerPart = "`r`n--$boundary--`r`n"
|
||||
|
||||
$headerBytes = $encoding.GetBytes($headerPart)
|
||||
@@ -125,7 +136,7 @@ function Send-EnoceanConfig {
|
||||
# Assembler le body complet en byte[]
|
||||
$bodyStream = New-Object System.IO.MemoryStream
|
||||
$bodyStream.Write($headerBytes, 0, $headerBytes.Length)
|
||||
$bodyStream.Write($ZipBytes, 0, $ZipBytes.Length)
|
||||
$bodyStream.Write($FileBytes, 0, $FileBytes.Length)
|
||||
$bodyStream.Write($footerBytes, 0, $footerBytes.Length)
|
||||
$bodyBytes = $bodyStream.ToArray()
|
||||
$bodyStream.Close()
|
||||
@@ -165,4 +176,37 @@ function Send-EnoceanConfig {
|
||||
}
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function Initialize-ApiClient, Get-AuthHeader, Invoke-EnoceanGet, Send-EnoceanConfig
|
||||
function Send-EnoceanConfig {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$BaseUrl,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[string]$ApiBasePath,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[byte[]]$ZipBytes,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[string]$ZipFilename,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Username,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[AllowEmptyString()]
|
||||
[string]$Password
|
||||
)
|
||||
|
||||
Send-MultipartFile `
|
||||
-BaseUrl $BaseUrl `
|
||||
-ApiBasePath $ApiBasePath `
|
||||
-ResourcePath "files/bacnet/inputConfiguration" `
|
||||
-FileBytes $ZipBytes `
|
||||
-Filename $ZipFilename `
|
||||
-Username $Username `
|
||||
-Password $Password
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function Initialize-ApiClient, Get-AuthHeader, Invoke-EnoceanGet, Send-MultipartFile, Send-EnoceanConfig
|
||||
|
||||
Reference in New Issue
Block a user