Skip to content

Commit

Permalink
Merge pull request #71 from nitrictech/refactor/storage-snippets
Browse files Browse the repository at this point in the history
refactor:  incorrect storage snippets
  • Loading branch information
davemooreuws authored Oct 19, 2021
2 parents 3ee0b1b + 1d1e75d commit 27b9d34
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
6 changes: 3 additions & 3 deletions examples/storage/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import { storage } from '@nitric/sdk';
export async function storageDelete() {
// [START snippet]
// Construct a new storage client with default settings
const storageClient = storage();
const sc = storage();

// Read a byte array from a bucket
const bytes = storageClient.bucket('my-bucket').file('path/to/item').delete();
// Delete a file from a bucket
await sc.bucket('my-bucket').file('path/to/item').delete();
// [END snippet]
}
7 changes: 2 additions & 5 deletions examples/storage/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ import { storage } from '@nitric/sdk';
export async function storageRead() {
// [START snippet]
// Construct a new storage client with default settings
const storageClient = storage();
const sc = storage();

// Read a byte array from a bucket
const bytes = await storageClient
.bucket('my-bucket')
.file('path/to/item')
.read();
const bytes = await sc.bucket('my-bucket').file('path/to/item').read();
// [END snippet]
}
4 changes: 2 additions & 2 deletions examples/storage/signed-url-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { storage, FileMode } from '@nitric/sdk';
export async function storagePresignedUrlRead() {
// [START snippet]
// Construct a new storage client with default settings
const storageClient = storage();
const sc = storage();

// Get a signed url for reading a file
const url = await storageClient
const url = await sc
.bucket('my-bucket')
.file('path/to/item')
.signUrl(FileMode.Read, {
Expand Down
4 changes: 2 additions & 2 deletions examples/storage/signed-url-write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { storage, FileMode } from '@nitric/sdk';
export async function storagePresignedUrlWrite() {
// [START snippet]
// Construct a new storage client with default settings
const storageClient = storage();
const sc = storage();

// Get a signed url for for uploading file
const url = await storageClient
const url = await sc
.bucket('my-bucket')
.file('path/to/item')
.signUrl(FileMode.Write, {
Expand Down
5 changes: 2 additions & 3 deletions examples/storage/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import { storage } from '@nitric/sdk';
export async function storageWrite() {
// [START snippet]
// Construct a new storage client with default settings
// Construct a new storage client with default settings
const storageClient = storage();
const sc = storage();

// Example byte array
const contents = new Uint8Array();

// Write a byte array to a bucket
storageClient.bucket('my-bucket').file('path/to/item').write(contents);
await sc.bucket('my-bucket').file('path/to/item').write(contents);
// [END snippet]
}

0 comments on commit 27b9d34

Please sign in to comment.