Skip to content

Commit 5df4cd5

Browse files
docs: token described as access token and move fullpath concept (#600)
* docs: token described as access token and move fullpath concept Signed-off-by: David Dal Busco <[email protected]> * 📄 Update LLMs.txt snapshot for PR review --------- Signed-off-by: David Dal Busco <[email protected]> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 43f6e83 commit 5df4cd5

File tree

2 files changed

+96
-68
lines changed

2 files changed

+96
-68
lines changed

.llms-snapshots/llms-full.txt

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,9 +2463,49 @@ If you're looking to extend backend capabilities using serverless logic, refer t
24632463

24642464
---
24652465

2466-
## Upload file
2466+
## Concepts
24672467

2468-
When you upload a file, it becomes an **asset** stored in the Storage of your Satellite. Assets are accessible over the web and can be listed, deleted, or protected using tokens.
2468+
Before working with the Storage API, it's helpful to understand two key concepts: assets and `fullPath`.
2469+
2470+
### Assets
2471+
2472+
Uploaded files become **assets** stored in your Satellite's Storage. These assets are web-accessible and can be managed with permissions, access tokens, and custom paths.
2473+
2474+
### fullPath
2475+
2476+
A `fullPath` is the **unique path** of an asset within your Satellite's storage. It determines the asset’s public-facing URL and is used throughout the SDK to identify, retrieve, list, or delete the asset.
2477+
2478+
It always starts with a **slash**, and follows the structure:
2479+
2480+
```
2481+
/collection/filename
2482+
```
2483+
2484+
For example, uploading a file to the `"images"` collection with the filename `"logo.png"` results in:
2485+
2486+
```
2487+
/images/logo.png
2488+
```
2489+
2490+
#### Key points
2491+
2492+
* If the asset is **not part of the frontend**, the `fullPath` always includes the **collection** name.
2493+
* By default, the `fullPath` is automatically derived from the uploaded file's name (e.g. `/images/photo.jpg`).
2494+
* You can override the path using a custom filename. These are e.g. both valid:
2495+
* `/collection/hello.jpg`
2496+
* `/collection/my/sub/path/hello.jpg`
2497+
* The `fullPath` is effectively the **asset key** used in Juno Storage.
2498+
* ⚠️ Uploading a file to an existing `fullPath` will **overwrite** the existing file.
2499+
2500+
---
2501+
2502+
## Upload
2503+
2504+
The SDK provides multiple functions to upload files to your Satellite's Storage, each suited for different use cases.
2505+
2506+
---
2507+
2508+
### Upload file
24692509

24702510
To upload a file, use the following code:
24712511

@@ -2480,7 +2520,7 @@ The `data` parameter is the file you want to upload. This is a `Blob`, typically
24802520
The `uploadFile` function provides various options, including:
24812521

24822522
* `filename`: By default, Juno uses the file's filename. You can overwrite this and provide a custom filename. Example: `myimage.jpg`.
2483-
* `fullPath`: The unique path where the asset will be stored and accessed. 👉 See ([What is a `fullPath`?](#what-is-a-fullpath)) for details and examples.
2523+
* `fullPath`: The unique path where the asset will be stored and accessed.
24842524
* `headers`: The headers can affect how the browser handles the asset. If no headers are provided Juno will infer the `Content-Type` from the file type.
24852525
* `encoding`: The type of encoding for the file. For example, `identity` (raw) or `gzip`.
24862526

@@ -2496,35 +2536,9 @@ The function returns the uploaded asset key as an object with the following fiel
24962536
* `name`: The name of the asset (typically the filename). Example: `myimage.jpg`.
24972537
* `downloadUrl`: The URL to access the asset on the web or to download it. This URL can be used in a browser or embedded directly in HTML elements like `<img>` or `<a>`.
24982538

2499-
#### What is a `fullPath`?
2500-
2501-
The `fullPath` is the **unique path** of an asset within your Satellite's storage. It determines the asset’s public-facing URL and is used throughout the SDK to identify, retrieve, list, or delete the asset.
2502-
2503-
It always starts with a **slash**, and follows the structure:
2504-
2505-
```
2506-
/collection/filename
2507-
```
2508-
2509-
For example, uploading a file to the `"images"` collection with the filename `"logo.png"` results in:
2510-
2511-
```
2512-
/images/logo.png
2513-
```
2514-
2515-
#### Key points
2516-
2517-
* If the asset is **not part of the frontend**, the `fullPath` always includes the **collection** name.
2518-
* By default, the `fullPath` is automatically derived from the uploaded file's name (e.g. `/images/photo.jpg`).
2519-
* You can override the path using a custom filename. These are both valid:
2520-
* `/collection/hello.jpg`
2521-
* `/collection/my/sub/path/hello.jpg`
2522-
* The `fullPath` is effectively the **asset key** used in Juno Storage.
2523-
* ⚠️ Uploading a file to an existing `fullPath` will **overwrite** the existing file.
2524-
25252539
---
25262540

2527-
## Upload blob
2541+
### Upload blob
25282542

25292543
The `uploadBlob` function works like ([`uploadFile`](#upload-file)) but does **not** infer the filename from the data. You must explicitly provide the `filename`.
25302544

@@ -2536,17 +2550,17 @@ This is useful when uploading raw binary data that wasn't selected via a file in
25362550

25372551
---
25382552

2539-
## Protected assets
2553+
### Protected asset
25402554

25412555
While all assets can be found on the internet, it is possible to make their URL difficult to guess so that they remain undiscoverable (**as long as they are not shared**) and considered "private".
25422556

2543-
Juno achieves this by using an optional `token` query parameter.
2557+
Juno achieves this by using an optional access `token` query parameter.
25442558

25452559
```
25462560
import { uploadFile } from "@junobuild/core";import { nanoid } from "nanoid";const result = await uploadFile({ data, collection: "images", token: nanoid()});
25472561
```
25482562

2549-
Imagine a file "mydata.jpg" uploaded with a token. Attempting to access it through the URL "[https://yoursatellite/mydata.jpg](https://yoursatellite/mydata.jpg)" will not work. The asset can only be retrieved if a token is provided: "[https://yoursatellite/mydata.jpg?token=a-super-long-secret-id](https://yoursatellite/mydata.jpg?token=a-super-long-secret-id)".
2563+
Imagine a file "mydata.jpg" uploaded with an access token. Attempting to access it through the URL "[https://yoursatellite/mydata.jpg](https://yoursatellite/mydata.jpg)" will not work. The asset can only be retrieved if a `token` parameter is provided: "[https://yoursatellite/mydata.jpg?token=a-super-long-secret-id](https://yoursatellite/mydata.jpg?token=a-super-long-secret-id)".
25502564

25512565
---
25522566

@@ -2680,7 +2694,7 @@ import { downloadUrl } from "@junobuild/core";const url = downloadUrl({ assetKe
26802694

26812695
* **`fullPath`**: The full path to the asset (e.g., `/images/file.jpg`).
26822696

2683-
* **`token`** (optional): A secret token used to access protected assets.
2697+
* **`token`** (optional): A access token used to protect the asset.
26842698

26852699
* **`satellite`** (optional) Required only in Node.js environments to specify which Satellite to use.
26862700

docs/build/storage/development.mdx

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,49 @@ import ClientSide from "../components/client-side.mdx";
88

99
---
1010

11-
## Upload file
11+
## Concepts
1212

13-
When you upload a file, it becomes an **asset** stored in the Storage of your Satellite. Assets are accessible over the web and can be listed, deleted, or protected using tokens.
13+
Before working with the Storage API, it's helpful to understand two key concepts: assets and `fullPath`.
14+
15+
### Assets
16+
17+
Uploaded files become **assets** stored in your Satellite's Storage. These assets are web-accessible and can be managed with permissions, access tokens, and custom paths.
18+
19+
### fullPath
20+
21+
A `fullPath` is the **unique path** of an asset within your Satellite's storage. It determines the asset’s public-facing URL and is used throughout the SDK to identify, retrieve, list, or delete the asset.
22+
23+
It always starts with a **slash**, and follows the structure:
24+
25+
```
26+
/collection/filename
27+
```
28+
29+
For example, uploading a file to the `"images"` collection with the filename `"logo.png"` results in:
30+
31+
```
32+
/images/logo.png
33+
```
34+
35+
#### Key points
36+
37+
- If the asset is **not part of the frontend**, the `fullPath` always includes the **collection** name.
38+
- By default, the `fullPath` is automatically derived from the uploaded file's name (e.g. `/images/photo.jpg`).
39+
- You can override the path using a custom filename. These are e.g. both valid:
40+
- `/collection/hello.jpg`
41+
- `/collection/my/sub/path/hello.jpg`
42+
- The `fullPath` is effectively the **asset key** used in Juno Storage.
43+
- ⚠️ Uploading a file to an existing `fullPath` will **overwrite** the existing file.
44+
45+
---
46+
47+
## Upload
48+
49+
The SDK provides multiple functions to upload files to your Satellite's Storage, each suited for different use cases.
50+
51+
---
52+
53+
### Upload file
1454

1555
To upload a file, use the following code:
1656

@@ -30,7 +70,7 @@ The `data` parameter is the file you want to upload. This is a `Blob`, typically
3070
The `uploadFile` function provides various options, including:
3171

3272
- `filename`: By default, Juno uses the file's filename. You can overwrite this and provide a custom filename. Example: `myimage.jpg`.
33-
- `fullPath`: The unique path where the asset will be stored and accessed.<br />👉 See [What is a `fullPath`?](#what-is-a-fullpath) for details and examples.
73+
- `fullPath`: The unique path where the asset will be stored and accessed.
3474
- `headers`: The headers can affect how the browser handles the asset. If no headers are provided Juno will infer the `Content-Type` from the file type.
3575
- `encoding`: The type of encoding for the file. For example, `identity` (raw) or `gzip`.
3676

@@ -48,35 +88,9 @@ The function returns the uploaded asset key as an object with the following fiel
4888
- `name`: The name of the asset (typically the filename). Example: `myimage.jpg`.
4989
- `downloadUrl`: The URL to access the asset on the web or to download it. This URL can be used in a browser or embedded directly in HTML elements like `<img>` or `<a>`.
5090

51-
#### What is a `fullPath`?
52-
53-
The `fullPath` is the **unique path** of an asset within your Satellite's storage. It determines the asset’s public-facing URL and is used throughout the SDK to identify, retrieve, list, or delete the asset.
54-
55-
It always starts with a **slash**, and follows the structure:
56-
57-
```
58-
/collection/filename
59-
```
60-
61-
For example, uploading a file to the `"images"` collection with the filename `"logo.png"` results in:
62-
63-
```
64-
/images/logo.png
65-
```
66-
67-
#### Key points
68-
69-
- If the asset is **not part of the frontend**, the `fullPath` always includes the **collection** name.
70-
- By default, the `fullPath` is automatically derived from the uploaded file's name (e.g. `/images/photo.jpg`).
71-
- You can override the path using a custom filename. These are both valid:
72-
- `/collection/hello.jpg`
73-
- `/collection/my/sub/path/hello.jpg`
74-
- The `fullPath` is effectively the **asset key** used in Juno Storage.
75-
- ⚠️ Uploading a file to an existing `fullPath` will **overwrite** the existing file.
76-
7791
---
7892

79-
## Upload blob
93+
### Upload blob
8094

8195
The `uploadBlob` function works like [`uploadFile`](#upload-file) but does **not** infer the filename from the data.
8296
You must explicitly provide the `filename`.
@@ -95,11 +109,11 @@ This is useful when uploading raw binary data that wasn't selected via a file in
95109

96110
---
97111

98-
## Protected assets
112+
### Protected asset
99113

100114
While all assets can be found on the internet, it is possible to make their URL difficult to guess so that they remain undiscoverable (**as long as they are not shared**) and considered "private".
101115

102-
Juno achieves this by using an optional `token` query parameter.
116+
Juno achieves this by using an optional access `token` query parameter.
103117

104118
```typescript
105119
import { uploadFile } from "@junobuild/core";
@@ -112,7 +126,7 @@ const result = await uploadFile({
112126
});
113127
```
114128

115-
Imagine a file "mydata.jpg" uploaded with a token. Attempting to access it through the URL "https://yoursatellite/mydata.jpg" will not work. The asset can only be retrieved if a token is provided: "https://yoursatellite/mydata.jpg?token=a-super-long-secret-id".
129+
Imagine a file "mydata.jpg" uploaded with an access token. Attempting to access it through the URL "https://yoursatellite/mydata.jpg" will not work. The asset can only be retrieved if a `token` parameter is provided: "https://yoursatellite/mydata.jpg?token=a-super-long-secret-id".
116130

117131
---
118132

@@ -320,7 +334,7 @@ const url = downloadUrl({
320334

321335
- **`assetKey`** (required)
322336
- **`fullPath`**: The full path to the asset (e.g., `/images/file.jpg`).
323-
- **`token`** (optional): A secret token used to access protected assets.
337+
- **`token`** (optional): A access token used to protect the asset.
324338

325339
- **`satellite`** (optional)
326340
Required only in Node.js environments to specify which Satellite to use.

0 commit comments

Comments
 (0)