Skip to content

Commit 15bf4ba

Browse files
committed
docs: add gaxios and node 18 migration guide
1 parent 72c17d7 commit 15bf4ba

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

handwritten/storage/MIGRATION.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Storage v7 to v8 Migration Guide - Gaxios Update
2+
3+
This guide helps you migrate your application from `@google-cloud/storage` v7 to v8, focusing on the changes introduced by the update of the underlying HTTP client, `gaxios`, to version 7.
4+
5+
## Key Breaking Changes for Storage Users
6+
7+
### 1. Response Headers are now `Headers` objects
8+
9+
When you receive a full API response from Storage methods (e.g., via callbacks or promise resolutions that include the response object), the `headers` property of the response is now a standard `Headers` object rather than a plain JavaScript object.
10+
11+
**Before (Storage v7):**
12+
13+
```js
14+
const [file, apiResponse] = await file.get();
15+
const contentType = apiResponse.headers['content-type'];
16+
```
17+
18+
**After (Storage v8):**
19+
20+
```js
21+
const [file, apiResponse] = await file.get();
22+
// Accessing headers requires the .get() method
23+
const contentType = apiResponse.headers.get('content-type');
24+
```
25+
26+
### 2. Passing Headers in Options
27+
28+
If you pass custom headers in options to Storage methods (which extend `GaxiosOptions`), you can still pass plain objects, as the Storage library will convert them to `Headers` internally for the request. However, if you read them back from the prepared options or response, they will be `Headers` objects.
29+
30+
### 3. URL Resolution (`baseURL`)
31+
32+
If you are using custom `baseURL` options or passing relative URLs to methods that accept them, be aware that resolution now strictly follows the `URL` constructor spec (`new URL(url, baseURL)`).
33+
34+
## Upgrade Instructions
35+
36+
Update your `@google-cloud/storage` dependency to version 8:
37+
38+
```sh
39+
npm install @google-cloud/storage@latest
40+
```
41+
42+
## Troubleshooting
43+
44+
- If you encounter `undefined` when accessing headers on the response object, ensure you are using `apiResponse.headers.get('header-name')`.

0 commit comments

Comments
 (0)