Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Mar 19, 2024
1 parent d3b794a commit 3adb31d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,36 @@ main();

Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.

## File Uploads

Request parameters that correspond to file uploads can be passed in many different forms:

- `File` (or an object with the same structure)
- a `fetch` `Response` (or an object with the same structure)
- an `fs.ReadStream`
- the return value of our `toFile` helper

```ts
import fs from 'fs';
import fetch from 'node-fetch';
import Cloudflare, { toFile } from 'cloudflare';

const cloudflare = new Cloudflare();

// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
await cloudflare.images.v1.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' });

// Or if you have the web `File` API you can pass a `File` instance:
await cloudflare.images.v1.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' });

// You can also pass a `fetch` `Response`:
await cloudflare.images.v1.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' });

// Finally, if none of the above are convenient, you can use our `toFile` helper:
await cloudflare.images.v1.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' });
await cloudflare.images.v1.create({ account_id: '023e105f4ecef8ad9ca31a8372d0c353' });
```

## Handling errors

When the library is unable to connect to the API,
Expand Down

0 comments on commit 3adb31d

Please sign in to comment.