Skip to content

Commit

Permalink
docs: update serve example
Browse files Browse the repository at this point in the history
resolves #136
  • Loading branch information
atinux committed Jun 4, 2024
1 parent 516fb4a commit 3a06bed
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions docs/content/1.docs/2.storage/3.blob.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,21 @@ Returns [`BlobListResult`](#bloblistresult).

Returns a blob's data.

```ts [server/api/files/[...pathname\\].get.ts]

::code-group
```ts [server/routes/images/[...pathname\\].get.ts]
export default eventHandler(async (event) => {
const { pathname } = getRouterParams(event)

return hubBlob().serve(event, pathname)
})
```
```vue [pages/index.vue]
<template>
<img src="/images/my-image.jpg">
</template>
```
::

#### Params

Expand All @@ -84,14 +92,6 @@ export default eventHandler(async (event) => {

Returns the blob's raw data and sets `Content-Type` and `Content-Length` headers.

::callout{icon="i-heroicons-information-circle" class="prose-code:bg-gray-50 dark:prose-code:bg-gray-800"}
If you are fetching an image with a server route similar to the one above, you might simply want to use it this way:
<br>
```vue
<img :src="`/api/blob/${file.pathname}`">
```
::

### `head()`

Returns a blob's metadata.
Expand Down

0 comments on commit 3a06bed

Please sign in to comment.