diff --git a/src/Services/EntrepotApi/MetadataApi.php b/src/Services/EntrepotApi/MetadataApi.php index a5fef9f7..6c313dbe 100644 --- a/src/Services/EntrepotApi/MetadataApi.php +++ b/src/Services/EntrepotApi/MetadataApi.php @@ -19,14 +19,14 @@ public function get(string $datastoreId, string $metadataId): array public function add(string $datastoreId, string $filepath, string $type): array { - return $this->postFile("datastores/$datastoreId/metadata", $filepath, [], [ + return $this->sendFile('POST', "datastores/$datastoreId/metadata", $filepath, [], [ 'type' => $type, ]); } public function replaceFile(string $datastoreId, string $metadataId, string $filepath): array { - return $this->postFile("datastores/$datastoreId/metadata/$metadataId", $filepath); + return $this->sendFile('PUT', "datastores/$datastoreId/metadata/$metadataId", $filepath); } /** diff --git a/src/Services/EntrepotApi/StaticApi.php b/src/Services/EntrepotApi/StaticApi.php index 4611959d..c849e18b 100644 --- a/src/Services/EntrepotApi/StaticApi.php +++ b/src/Services/EntrepotApi/StaticApi.php @@ -9,7 +9,7 @@ class StaticApi extends AbstractEntrepotApiService */ public function getAll(string $datastoreId, $query = []): array { - return $this->request('GET', "datastores/$datastoreId/statics", [], $query); + return $this->requestAll("datastores/$datastoreId/statics", $query); } public function get(string $datastoreId, string $staticId): array @@ -28,12 +28,20 @@ public function add(string $datastoreId, string $filepath, string $name, string $formFields['description'] = $description; } - return $this->postFile("datastores/$datastoreId/statics", $filepath, $formFields); + $response = $this->sendFile('POST', "datastores/$datastoreId/statics", $filepath, $formFields); + + $this->filesystem->remove($filepath); + + return $response; } public function replaceFile(string $datastoreId, string $staticId, string $filepath): array { - return $this->postFile("datastores/$datastoreId/statics/$staticId", $filepath); + $response = $this->sendFile('PUT', "datastores/$datastoreId/statics/$staticId", $filepath); + + $this->filesystem->remove($filepath); + + return $response; } public function delete(string $datastoreId, string $staticId): array diff --git a/src/Services/EntrepotApi/UploadApiService.php b/src/Services/EntrepotApi/UploadApiService.php index 48e0977d..0e703d27 100644 --- a/src/Services/EntrepotApi/UploadApiService.php +++ b/src/Services/EntrepotApi/UploadApiService.php @@ -127,7 +127,7 @@ public function addFile($datastoreId, $uploadId, $filename) public function uploadFile($datastoreId, $uploadId, $pathname, $filename) { // posting the file itself - $this->postFile("datastores/$datastoreId/uploads/$uploadId/data", $pathname, [ + $this->sendFile('POST', "datastores/$datastoreId/uploads/$uploadId/data", $pathname, [ 'path' => 'data', ]); @@ -136,7 +136,7 @@ public function uploadFile($datastoreId, $uploadId, $pathname, $filename) $md5filePath = "$pathname.md5"; file_put_contents($md5filePath, "$md5 data/$filename"); - $this->postFile("datastores/$datastoreId/uploads/$uploadId/md5", $md5filePath); + $this->sendFile('POST', "datastores/$datastoreId/uploads/$uploadId/md5", $md5filePath); $this->filesystem->remove($pathname); $this->filesystem->remove($md5filePath); diff --git a/src/Services/EntrepotApiService.php b/src/Services/EntrepotApiService.php index 60f17ab5..09a12662 100644 --- a/src/Services/EntrepotApiService.php +++ b/src/Services/EntrepotApiService.php @@ -9,6 +9,7 @@ use App\Services\EntrepotApi\DatastoreApiService; use App\Services\EntrepotApi\MetadataApi; use App\Services\EntrepotApi\ProcessingApiService; +use App\Services\EntrepotApi\StaticApi; use App\Services\EntrepotApi\StoredDataApiService; use App\Services\EntrepotApi\UploadApiService; use App\Services\EntrepotApi\UserApiService; @@ -26,6 +27,7 @@ public function __construct( public readonly AnnexeApiService $annexe, public readonly CommunityApiService $community, public readonly MetadataApi $metadata, + public readonly StaticApi $static, ) { $this->user->setEntrepotApiService($this); $this->datastore->setEntrepotApiService($this); @@ -37,5 +39,6 @@ public function __construct( $this->annexe->setEntrepotApiService($this); $this->community->setEntrepotApiService($this); $this->metadata->setEntrepotApiService($this); + $this->static->setEntrepotApiService($this); } }