Browse Source

Update Archive.php

main
HNA 2 years ago
parent
commit
f9f4fbf0a7
1 changed files with 11 additions and 9 deletions
  1. +11
    -9
      SamApiLib/Archive.php

+ 11
- 9
SamApiLib/Archive.php View File

@ -184,7 +184,7 @@ class Archive
* @param $file_plan_position * @param $file_plan_position
* @return array[]|mixed[] * @return array[]|mixed[]
*/ */
public function createArchiveWithResource ($archiveId, $originatorOwnerOrgRegNumber, $originatorOrgRegNumber, $content, $file_name, $hash, $hashAlgorithm)
public function createArchiveWithResources ($archiveId, $originatorOwnerOrgRegNumber, $originatorOrgRegNumber, $contents, $file_names, $hashs, $hashAlgorithms)
{ {
$ws_route = " post /digitalSafe/digitalSafe/{originatorOwnerOrgRegNumber}/{originatorOrgRegNumber}"; $ws_route = " post /digitalSafe/digitalSafe/{originatorOwnerOrgRegNumber}/{originatorOrgRegNumber}";
$url_params = [ $url_params = [
@ -192,16 +192,18 @@ class Archive
"originatorOrgRegNumber" => $originatorOrgRegNumber "originatorOrgRegNumber" => $originatorOrgRegNumber
]; ];
$query_params = []; $query_params = [];
$digitalResources = [];
foreach ($contents as $key => $content) {
$digitalResources[] = [
"handler" => base64_encode($content),
"fileName" => $file_names[$key],
"hash" => $hashs[$key],
"hashAlgorithm" => $hashAlgorithms[$key]
];
}
$body_params = [ $body_params = [
"originatorArchiveId" => $archiveId, "originatorArchiveId" => $archiveId,
"digitalResources" => [
[
"handler" => base64_encode($content),
"fileName" => $file_name,
"hash" => $hash,
"hashAlgorithm" => $hashAlgorithm
]
]
"digitalResources" => $digitalResources
]; ];
list($headers, $body) = $this->sam_api->query($ws_route, $url_params, $query_params, $body_params); list($headers, $body) = $this->sam_api->query($ws_route, $url_params, $query_params, $body_params);
return $body; return $body;


Loading…
Cancel
Save