Skip to content

Commit f73c05f

Browse files
committed
Update code example for artifact files edit
1 parent c97bb0f commit f73c05f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,13 +610,20 @@ $client->packages()->artifacts()->add($packageName, $file, 'application/zip', $f
610610

611611
```php
612612
// in case you want to replace the artifact file with a newly uploaded one
613-
// 1. upload the new artifact file
613+
// 1. get current artifact ids
614+
$result = $client->packages()->artifacts()->showPackageArtifacts('acme-website/package');
615+
$artifactIds = array_column($result, 'id'); // [41, 42]
616+
617+
// 2. upload the new artifact file
614618
$fileName = 'package1.zip';
615619
$file = file_get_contents($fileName);
616620
$response = $client->packages()->artifacts()->create($file, 'application/zip', $fileName);
617-
$artifactId = $response['id'];
618-
// 2. send the artifact file ids you want to use for the package
619-
$client->packages()->editArtifactPackage('acme-website/package', [$artifactId, 42]);
621+
$newArtifactId = $response['id'];
622+
623+
// 3. let's say we don't want to have the artifact file id = 41 and use the newly uploaded file instead
624+
$artifactIds = array_shift($artifactIds);
625+
$artifactIds[] = $newArtifactId;
626+
$client->packages()->editArtifactPackage('acme-website/package', $artifactIds);
620627
```
621628

622629
### Credential

0 commit comments

Comments
 (0)