Skip to content

Commit

Permalink
fix: correction après modification sendFile
Browse files Browse the repository at this point in the history
  • Loading branch information
ocruze committed Nov 21, 2023
1 parent 746ce97 commit 0f2ebba
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Services/EntrepotApi/MetadataApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
14 changes: 11 additions & 3 deletions src/Services/EntrepotApi/StaticApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Services/EntrepotApi/UploadApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);

Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/Services/EntrepotApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -37,5 +39,6 @@ public function __construct(
$this->annexe->setEntrepotApiService($this);
$this->community->setEntrepotApiService($this);
$this->metadata->setEntrepotApiService($this);
$this->static->setEntrepotApiService($this);
}
}

0 comments on commit 0f2ebba

Please sign in to comment.