We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c1cb94a + 13a77b3 commit c24290bCopy full SHA for c24290b
src/api/storage/v0/storage.ts
@@ -195,11 +195,15 @@ export class File {
195
* await storage.bucket("my-bucket").file("my-item").write(buf);
196
* ```
197
*/
198
- public async write (body: Uint8Array): Promise<void> {
+ public async write (body: Uint8Array | string): Promise<void> {
199
const request = new StorageWriteRequest();
200
request.setBucketName(this.bucket.name);
201
request.setKey(this.name);
202
- request.setBody(body);
+ if (typeof body === 'string' || body instanceof String) {
203
+ request.setBody(new TextEncoder().encode(body as string))
204
+ } else {
205
+ request.setBody(body);
206
+ }
207
208
return new Promise((resolve, reject) => {
209
this.storage.StorageServiceClient.write(request, (error) => {
0 commit comments