Skip to content

Commit 3d60177

Browse files
committed
client accepting same body type as guzzle, readme update
1 parent 80baa0c commit 3d60177

File tree

2 files changed

+39
-13
lines changed

2 files changed

+39
-13
lines changed

README.md

+33-12
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,58 @@ PHP Client for Vercel Blob Storage.
1212
$client = new \VercelBlobPhp\Client();
1313
```
1414

15+
Client constructor accepts token for blob storage, but if you connected your blob storage to project then you don't need to set it.
16+
1517
### Using Client
1618

1719
#### PUT
1820
```php
1921
$result = $client->put(
20-
'test.txt', // path
21-
'hello world' // content,
22-
new \VercelBlobPhp\CommonCreateBlobOptions(
22+
path: 'test.txt', // path
23+
content: 'hello world' // content,
24+
options: new \VercelBlobPhp\CommonCreateBlobOptions(
2325
addRandomSuffix: true, // optional
2426
contentType: 'text', // optional
2527
cacheControlMaxAge: 123, // optional
2628
)
2729
);
28-
29-
// $result is instance of PutBlobResult
30-
$result->url
31-
$result->downloadUrl
32-
$result->pathname
33-
$result->contentType
34-
$result->contentDisposition
3530
```
3631

37-
Third argument is optional.
32+
Options argument is optional.
3833

3934
#### DEL
4035
```php
4136
$client->del(['test.txt']);
4237
```
4338

4439
#### COPY
40+
```php
41+
$result = $client->copy(
42+
fromUrl: 'fromUrl',
43+
toPathname: 'toPathname',
44+
options: new \VercelBlobPhp\CommonCreateBlobOptions(
45+
addRandomSuffix: true, // optional
46+
contentType: 'text', // optional
47+
cacheControlMaxAge: 123, // optional
48+
)
49+
);
50+
```
4551

4652
#### HEAD
53+
```php
54+
$result = $client->head('url');
55+
```
56+
57+
#### LIST
58+
```php
59+
$result = $client->list(
60+
options: new \VercelBlobPhp\ListCommandOptions(
61+
limit: 100, // optional
62+
cursor: 'cursor', // optional
63+
mode: \VercelBlobPhp\ListCommandMode::EXPANDED, // optional
64+
prefix: 'prefix', // optional
65+
)
66+
);
67+
```
4768

48-
#### LIST
69+
Options argument is optional.

src/Client.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
use GuzzleHttp\Client as GuzzleClient;
88
use GuzzleHttp\Exception\ClientException;
99
use GuzzleHttp\Exception\GuzzleException;
10+
use Iterator;
1011
use JsonException;
1112
use Psr\Http\Message\ResponseInterface;
13+
use Psr\Http\Message\StreamInterface;
1214
use VercelBlobPhp\Exception\BlobAccessException;
1315
use VercelBlobPhp\Exception\BlobException;
1416
use VercelBlobPhp\Exception\BlobNotFoundException;
@@ -83,6 +85,8 @@ public function request(string $uri, string $method, array $options = []): Respo
8385
}
8486

8587
/**
88+
* @param resource|string|null|int|float|StreamInterface|callable|Iterator $content
89+
*
8690
* @return PutBlobResult
8791
* @throws BlobAccessException
8892
* @throws BlobException
@@ -95,7 +99,7 @@ public function request(string $uri, string $method, array $options = []): Respo
9599
* @throws GuzzleException
96100
* @throws JsonException
97101
*/
98-
public function put(string $path, string $content, ?CommonCreateBlobOptions $options = null): PutBlobResult
102+
public function put(string $path, $content, ?CommonCreateBlobOptions $options = null): PutBlobResult
99103
{
100104
$body = $this->getResponseBody(
101105
$this->request(
@@ -119,6 +123,7 @@ public function put(string $path, string $content, ?CommonCreateBlobOptions $opt
119123

120124
/**
121125
* @param string[] $urls
126+
*
122127
* @throws BlobAccessException
123128
* @throws BlobException
124129
* @throws BlobNotFoundException

0 commit comments

Comments
 (0)