-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0ddfde
commit b515868
Showing
7 changed files
with
162 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: DownloadURL Component | ||
pubDate: 2023-07-23 | ||
description: SvelteFire DownloadURL Component API reference | ||
layout: ../../layouts/MainLayout.astro | ||
--- | ||
|
||
# DownloadURL | ||
|
||
Returns the download URL for a file in Firebase Storage. | ||
|
||
### Props | ||
|
||
- `ref` - A Firebase Storage reference or path string (e.g. `files/hi-mom.txt`) | ||
|
||
### Slots | ||
|
||
- `default` - Shown when the url is available | ||
- `loading` - Shown while the url is loading | ||
|
||
### Slot Props | ||
|
||
- `link` - The download URL | ||
- `ref` - Storage reference | ||
- `storage` - The Firestore instance | ||
|
||
### Example | ||
|
||
```svelte | ||
<script> | ||
import { DownloadURL } from "sveltefire"; | ||
</script> | ||
<DownloadURL ref="images/pic.png" let:link let:ref> | ||
<!-- show img --> | ||
<img src={link} /> | ||
<!-- or download via link --> | ||
<a href={link} download>{ref?.name}</a> | ||
</DownloadURL> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
title: StorageList Component | ||
pubDate: 2023-07-23 | ||
description: SvelteFire StorageList Component API reference | ||
layout: ../../layouts/MainLayout.astro | ||
--- | ||
|
||
# StorageList | ||
|
||
Returns a list of files stored in Firebase Storage. | ||
|
||
### Props | ||
|
||
- `ref` - A Firebase Storage reference or path string (e.g. `files/hi-mom.txt`) | ||
|
||
### Slots | ||
|
||
- `default` - Shown when the list is available | ||
- `loading` - Shown while the list is loading | ||
|
||
### Slot Props | ||
|
||
- `list` - The list of files and prefixes | ||
- `ref` - Storage reference | ||
- `storage` - The Firestore instance | ||
|
||
### Example | ||
|
||
```svelte | ||
<script> | ||
import { StorageList } from "sveltefire"; | ||
</script> | ||
<StorageList ref="images/uid" let:list> | ||
<ul> | ||
{#if list === null} | ||
<li>Loading...</li> | ||
{:else if list.prefixes.length === 0 && list.items.length === 0} | ||
<li>Empty</li> | ||
{:else} | ||
<!-- Listing the prefixes --> | ||
{#each list.prefixes as prefix} | ||
<li> | ||
{prefix.name} | ||
</li> | ||
{/each} | ||
<!-- Listing the objects in the given folder --> | ||
{#each list.items as item} | ||
<li> | ||
{item.name} | ||
</li> | ||
{/each} | ||
{/if} | ||
</ul> | ||
</StorageList> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: UploadTask Component | ||
pubDate: 2023-07-23 | ||
description: SvelteFire UploadTask Component API reference | ||
layout: ../../layouts/MainLayout.astro | ||
--- | ||
|
||
# UploadTask | ||
|
||
Uploads a file to a Firebase storage bucket. | ||
|
||
### Props | ||
|
||
- `ref` - A Firebase Storage reference or path string (e.g. `files/hi-mom.txt`) | ||
- `data` - the file data to be uploaded as `Blob | Uint8Array | ArrayBuffer` | ||
- `metadata` - (optional) file metadata | ||
|
||
|
||
### Slots | ||
|
||
- `default` | ||
|
||
### Slot Props | ||
|
||
- `snapshot` - Firebase UploadTaskSnapshot | ||
- `task` - Firebase UploadTask | ||
- `progress` - Number as a percentage of the upload progress | ||
- `storage` - The Firestore instance | ||
|
||
### Example | ||
|
||
```svelte | ||
<script> | ||
import { DownloadURL, UploadTask } from "sveltefire"; | ||
let file; | ||
function chooseFile(e) { | ||
file = e.target.files[0]; | ||
} | ||
</script> | ||
<input type="file" on:change={chooseFile} /> | ||
{#if file} | ||
<UploadTask ref="myFile.txt" data={file} let:progress let:snapshot> | ||
{#if snapshot?.state === "running"} | ||
{progress}% uploaded | ||
{/if} | ||
{#if snapshot?.state === "success"} | ||
<DownloadURL ref={snapshot?.ref} let:link> | ||
<a href={link} download>Link</a> | ||
</DownloadURL> | ||
{/if} | ||
</UploadTask> | ||
{/if} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters