Skip to content

Commit dea0e4b

Browse files
author
Georg Martin Weber
committed
release 1.31.0, allow multiformData file upload
1 parent e046b81 commit dea0e4b

File tree

8 files changed

+106
-74
lines changed

8 files changed

+106
-74
lines changed

hull-vidispine-addon/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ Describes a particular entity on a subresource on an endpoint which is communica
186186
| `contentType` | The content type header for POST or PUT of the entity `config` and the accept header for all calls. Supported choices are `application/json`, `application/xml` and `text/plain`. Defaults to `application/json`. | `application/json` | `POST` <br> `PUT`
187187
| `postQueryParams` | Query Parameters to add to the Url of a POST command. Not a frequent use case but required to submit for example the `guid` of a UseCaseDefinition to migrate. | | `POST`
188188
| `putInsteadOfPost` | Some APIs use PUTting instead of POSTing for creation of new entities. If the subresource uses PUTting instead of POSTing, set this parameter to `true`. | `false` | `POST` <br> `PUT`
189+
| `multiPartFormData` | Setting this switch to `true` allows to POST single files as multiPartFormData. If `true`, the `config` section is expected to contain a single deliberately named key whose value is the relative file path to the file which is to be POSTed. For example, the following data will post the `myicon.svg` file to the API endpoint: <br><br>`multiPartFormData:`&#160;`true`<br>`config:`<br>&#160;&#160;`files:`&#160;`icons/myicon.svg`<br><br>Physical files need to be stored under `files/hull-vidispine-addon/installation/sources` or a direct subfolder of this path.| `false` | `POST`
189190
| `putUriExcludeIdentifier` | Some APIs handle PUTting of entities by PUTing to the parent resource and specifying the entity to create in the body. If the subresource handles PUTting in that way, set this parameter to `true`. If `false` or unspecified, PUT calls will be made to the path which ends with the entities __identifier__. | `false` | `PUT`
190191
| `putQueryParams` | Query Parameters to add to the Url of a PUT command. | | `PUT`
191192
| `remove` | The entity will be DELETEd if it exists. If both `register` and `remove` is true, any found entity is first removed if it exists before it is being created. | `false` | `DELETE`
Binary file not shown.
Binary file not shown.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependencies:
22
- name: hull
33
repository: https://vidispine.github.io/hull
4-
version: 1.31.0
5-
digest: sha256:adabeb4c7c3ccdf593c0015e5164eb105a87cb06d055108dad1dd39c14a9967b
6-
generated: "2024-09-26T16:39:19.8441659+02:00"
4+
version: 1.31.1
5+
digest: sha256:576263879bbb1616bb924f56a90e381218a44a3f7b4a201aa124a3fe6ec5d1d9
6+
generated: "2024-10-02T10:02:53.0596199+02:00"

hull-vidispine-addon/hull-vidispine-addon.yaml

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -644,60 +644,6 @@ hull:
644644
- custom-installation-files-setup
645645
- _HULL_OBJECT_TYPE_DEFAULT_
646646
data:
647-
installation.yaml:
648-
inline: |-
649-
{{- with (index $.Values "hull").config.general.data.installation }}
650-
{{- $configScope := . -}}
651-
{{- $configScopeEndpoints := dict -}}
652-
{{- if hasKey . "endpoints" -}}
653-
{{- $configScopeEndpoints = .endpoints -}}
654-
{{- end -}}
655-
{{- range $path, $_ := $.Files.Glob "files/hull-vidispine-addon/installation/endpoints/*.yaml" -}}
656-
{{- $configScopeEndpoints = mergeOverwrite $configScopeEndpoints (dict (base $path | trimSuffix ".yaml") (fromYaml ($.Files.Get $path))) -}}
657-
{{- end -}}
658-
{{- range $endpoint, $endpointval := $configScopeEndpoints -}}
659-
{{- $endpointScope := $endpointval -}}
660-
{{- if $endpointval.endpoint -}}
661-
{{- $subresources := dict -}}
662-
{{- if hasKey $endpointval "subresources" -}}
663-
{{- $subresources = $endpointval.subresources -}}
664-
{{- end -}}
665-
{{- range $path, $_ := $.Files.Glob (printf "%s/%s/%s" "files/hull-vidispine-addon/installation/endpoints" $endpoint "*.yaml") -}}
666-
{{- $subresources = mergeOverwrite $subresources (dict (base $path | trimSuffix ".yaml") (fromYaml ($.Files.Get $path))) -}}
667-
{{- end -}}
668-
{{- range $subresource, $subresourceval := $subresources }}
669-
{{- $subresourceScope := $subresourceval -}}
670-
{{- $entities := dict -}}
671-
{{- if hasKey $subresourceval "entities" -}}
672-
{{- $entities = $subresourceval.entities -}}
673-
{{- else -}}
674-
{{- $u := set $subresourceval "entities" dict }}
675-
{{- end -}}
676-
{{- range $path, $_ := $.Files.Glob (printf "%s/%s/%s/%s" "files/hull-vidispine-addon/installation/endpoints" $endpoint $subresource "*.yaml") -}}
677-
{{- $entities = mergeOverwrite $entities (dict (base $path | trimSuffix ".yaml") (fromYaml ($.Files.Get $path))) -}}
678-
{{- end -}}
679-
{{- range $entity, $entityval := $entities }}
680-
{{- $mergedDict := dict -}}
681-
{{- if hasKey $subresourceval "_DEFAULTS_" -}}
682-
{{- $mergedDict = deepCopy $subresourceval._DEFAULTS_ -}}
683-
{{- end -}}
684-
{{- $t := mergeOverwrite $mergedDict $entityval -}}
685-
{{- $z := set (index $.Values "hull").config.general.data.installation "endpoints" $configScopeEndpoints }}
686-
{{- if typeIs "map[string]interface {}" $mergedDict -}}
687-
{{- if hasKey $mergedDict "config" -}}
688-
{{- $configDict := $mergedDict.config -}}
689-
{{- end }}
690-
{{- end }}
691-
{{- $t1 := set $subresourceval.entities $entity $mergedDict -}}
692-
{{- end }}
693-
{{- end }}
694-
{{- else -}}
695-
{{- $configScopeEndpoints = unset $configScopeEndpoints $endpoint -}}
696-
{{- end }}
697-
{{- end }}
698-
{{- $_ := include "hull.util.transformation" (dict "PARENT_CONTEXT" $ "SOURCE" $configScope "CALLER" nil "CALLER_KEY" nil "SOURCE_PATH" list) -}}
699-
{{- toYaml $configScope -}}
700-
{{ end }}
701647
Installer.ps1:
702648
enabled: _HT*hull.config.general.data.installation.config.debug.debugInstallerScript
703649
inline: |-

images/hull-integration/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ RUN tar -zxf oras_${VERSION}_*.tar.gz -C oras-install/
1010
RUN mv oras-install/oras /usr/local/bin/
1111
RUN rm -rf oras_${VERSION}_*.tar.gz oras-install/
1212
COPY ./Installer.ps1 /script/Installer.ps1
13+
COPY ./installation.yaml /script/installation.yaml
1314
COPY ./get-custom-scripts /get-custom-scripts
1415
RUN oras --help

images/hull-integration/Installer.ps1

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,27 @@ Class Installer
321321
[Console]::ResetColor()
322322
}
323323

324+
[string] GetAbsoluteFilePath([string] $path)
325+
{
326+
# Get script path
327+
$currentPath = (Get-Item -Path ".\" -Verbose).FullName
328+
$filePath = ""
329+
if ($path -like "*/*" )
330+
{
331+
$split = $path.split('/')
332+
$filePath = Join-Path $currentPath "custom-installation-files-$($split[0])" $split[1]
333+
}
334+
else
335+
{
336+
$filePath = Join-Path $currentPath "custom-installation-files" $($path)
337+
}
338+
if (!(Test-Path $filePath))
339+
{
340+
throw [Exception]::new("ERROR --> File '$($filePath)' does not exist")
341+
}
342+
return $filePath
343+
}
344+
324345
hidden [string] LogInvokeWebRequestError()
325346
{
326347
return $this.LogInvokeWebRequestError($null, $null)
@@ -1103,7 +1124,7 @@ Class Installer
11031124
else
11041125
{
11051126
$this.WriteLog("**** POSTing '$entityType' entry '$identifier' to create it")
1106-
$this.PostEntity($apiEndpoint, $identifier, $content, $auth, $entity.postQueryParams, $contentType, $headers)
1127+
$this.PostEntity($apiEndpoint, $identifier, $content, $auth, $entity.postQueryParams, $contentType, $headers, $entity.multiPartFormData -eq $true)
11071128
$lastMethod = "POST"
11081129
$lastUri = $apiEndpoint
11091130
}
@@ -1118,11 +1139,36 @@ Class Installer
11181139
}
11191140

11201141
# Post an entity
1121-
hidden [PSCustomObject] PostEntity([string] $postUrl, [string] $identifier, [string] $json, [PSCustomObject] $auth, [PSCustomObject] $postQueryParams, [string] $contentType, [PSCustomObject] $headers)
1142+
hidden [PSCustomObject] PostEntity([string] $postUrl, [string] $identifier, [string] $json, [PSCustomObject] $auth, [PSCustomObject] $postQueryParams, [string] $contentType, [PSCustomObject] $headers, [bool] $multiPartFormData)
11221143
{
11231144
$this.WriteLog("**** 'URL before: $($postUrl)")
11241145
$url = $this.AppendQueryParamsToUri($postUrl, $postQueryParams, $identifier, $false)
11251146
$this.WriteLog("**** 'URL after: $($url)")
1147+
1148+
if ($multiPartFormData)
1149+
{
1150+
$decodedJson = $json | ConvertFrom-Json -AsHashTable
1151+
$multiPartFormDataField = @($decodedJson.Keys)[0]
1152+
$multiPartFormDataFilePath = $this.GetAbsoluteFilePath(@($decodedJson.Values)[0])
1153+
$multiPartFormDataFileName = Split-Path $multiPartFormDataFilePath -leaf
1154+
$this.WriteLog("***** MultiPartFormData: Field=$($multiPartFormDataField) FilePath=$($multiPartFormDataFilePath) FileName=$($multiPartFormDataFileName)'")
1155+
1156+
$fileBytes = [System.IO.File]::ReadAllBytes($multiPartFormDataFilePath);
1157+
$fileEncoded = [System.Text.Encoding]::GetEncoding('UTF-8').GetString($fileBytes);
1158+
$boundary = [System.Guid]::NewGuid().ToString();
1159+
$LF = "`r`n";
1160+
1161+
$json = (
1162+
"--$boundary",
1163+
"Content-Disposition: form-data; name=`"$($multiPartFormDataField)`"; filename=`"$($multiPartFormDataFileName)`"",
1164+
"Content-Type: application/octet-stream$LF",
1165+
$fileEncoded,
1166+
"--$boundary--$LF"
1167+
) -join $LF
1168+
1169+
$headers["Content-Type"] = "multipart/form-data; boundary=`"$boundary`""
1170+
}
1171+
11261172
return $this.InvokeWebRequest($url, "POST", $json, $headers)
11271173
}
11281174

@@ -1226,21 +1272,7 @@ Class Installer
12261272
if ([String]::IsNullOrEmpty($value))
12271273
{
12281274
$this.WriteLog("**** Determined file path '$($path)' as source for mapping'.")
1229-
$currentPath = (Get-Item -Path ".\" -Verbose).FullName
1230-
$filePath = ""
1231-
if ($path -like "*/*" )
1232-
{
1233-
$split = $path.split('/')
1234-
$filePath = Join-Path $currentPath "custom-installation-files-$($split[0])" $split[1]
1235-
}
1236-
else
1237-
{
1238-
$filePath = Join-Path $currentPath "custom-installation-files" $($path)
1239-
}
1240-
if (!(Test-Path $filePath))
1241-
{
1242-
throw [Exception]::new("ERROR --> File '$($filePath)' does not exist")
1243-
}
1275+
$filePath = $this.GetAbsoluteFilePath($path)
12441276
$this.WriteLog("**** External Config file found: " + $filePath)
12451277

12461278
$updateContent = Get-Content -Path $filePath | Out-String
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{{- with (index $.Values "hull").config.general.data.installation }}
2+
{{- $configScope := . -}}
3+
{{- $configScopeEndpoints := dict -}}
4+
{{- if hasKey . "endpoints" -}}
5+
{{- $configScopeEndpoints = .endpoints -}}
6+
{{- end -}}
7+
{{- range $path, $_ := $.Files.Glob "files/hull-vidispine-addon/installation/endpoints/*.yaml" -}}
8+
{{- $configScopeEndpoints = mergeOverwrite $configScopeEndpoints (dict (base $path | trimSuffix ".yaml") (fromYaml ($.Files.Get $path))) -}}
9+
{{- end -}}
10+
{{- range $endpoint, $endpointval := $configScopeEndpoints -}}
11+
{{- $endpointScope := $endpointval -}}
12+
{{- if $endpointval.endpoint -}}
13+
{{- $subresources := dict -}}
14+
{{- if hasKey $endpointval "subresources" -}}
15+
{{- $subresources = $endpointval.subresources -}}
16+
{{- end -}}
17+
{{- range $path, $_ := $.Files.Glob (printf "%s/%s/%s" "files/hull-vidispine-addon/installation/endpoints" $endpoint "*.yaml") -}}
18+
{{- $subresources = mergeOverwrite $subresources (dict (base $path | trimSuffix ".yaml") (fromYaml ($.Files.Get $path))) -}}
19+
{{- end -}}
20+
{{- range $subresource, $subresourceval := $subresources }}
21+
{{- $subresourceScope := $subresourceval -}}
22+
{{- $entities := dict -}}
23+
{{- if hasKey $subresourceval "entities" -}}
24+
{{- $entities = $subresourceval.entities -}}
25+
{{- else -}}
26+
{{- $u := set $subresourceval "entities" dict }}
27+
{{- end -}}
28+
{{- range $path, $_ := $.Files.Glob (printf "%s/%s/%s/%s" "files/hull-vidispine-addon/installation/endpoints" $endpoint $subresource "*.yaml") -}}
29+
{{- $entities = mergeOverwrite $entities (dict (base $path | trimSuffix ".yaml") (fromYaml ($.Files.Get $path))) -}}
30+
{{- end -}}
31+
{{- range $entity, $entityval := $entities }}
32+
{{- $mergedDict := dict -}}
33+
{{- if hasKey $subresourceval "_DEFAULTS_" -}}
34+
{{- $mergedDict = deepCopy $subresourceval._DEFAULTS_ -}}
35+
{{- end -}}
36+
{{- $t := mergeOverwrite $mergedDict $entityval -}}
37+
{{- $z := set (index $.Values "hull").config.general.data.installation "endpoints" $configScopeEndpoints }}
38+
{{- if typeIs "map[string]interface {}" $mergedDict -}}
39+
{{- if hasKey $mergedDict "config" -}}
40+
{{- $configDict := $mergedDict.config -}}
41+
{{- end }}
42+
{{- end }}
43+
{{- $t1 := set $subresourceval.entities $entity $mergedDict -}}
44+
{{- end }}
45+
{{- end }}
46+
{{- else -}}
47+
{{- $configScopeEndpoints = unset $configScopeEndpoints $endpoint -}}
48+
{{- end }}
49+
{{- end }}
50+
{{- $_ := include "hull.util.transformation" (dict "PARENT_CONTEXT" $ "SOURCE" $configScope "CALLER" nil "CALLER_KEY" nil "SOURCE_PATH" list) -}}
51+
{{- toYaml $configScope -}}
52+
{{ end }}

0 commit comments

Comments
 (0)