Skip to content

Commit 05ee09a

Browse files
committed
Improve readme examples.
1 parent b62c460 commit 05ee09a

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

readme.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,14 @@ function UploadBlob() {
149149
type="text"
150150
required
151151
onChange={({ target: { validity, value } }) => {
152-
if (validity.valid) {
153-
const file = new Blob([value], {
154-
type: "text/plain",
155-
});
156-
157-
// Optional, defaults to `blob`.
158-
file.name = "text.txt";
159-
152+
if (validity.valid)
160153
mutate({
161154
variables: {
162-
file,
155+
file: new Blob([value], {
156+
type: "text/plain",
157+
}),
163158
},
164159
});
165-
}
166160
}}
167161
/>
168162
);
@@ -177,6 +171,19 @@ const mutation = gql`
177171
`;
178172
```
179173

174+
To avoid the upload default file name `blob`, replace the `Blob` approach with `File`:
175+
176+
```ts
177+
new File(
178+
[value],
179+
// Custom file name.
180+
"text.txt",
181+
{
182+
type: "text/plain",
183+
},
184+
);
185+
```
186+
180187
## Requirements
181188

182189
- [Node.js](https://nodejs.org) versions `^20.9.0 || >=22.0.0`.

0 commit comments

Comments
 (0)