You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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>
Copy file name to clipboardExpand all lines: .llms-snapshots/llms-full.txt
+48-34Lines changed: 48 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -2463,9 +2463,49 @@ If you're looking to extend backend capabilities using serverless logic, refer t
2463
2463
2464
2464
---
2465
2465
2466
-
## Upload file
2466
+
## Concepts
2467
2467
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
2469
2509
2470
2510
To upload a file, use the following code:
2471
2511
@@ -2480,7 +2520,7 @@ The `data` parameter is the file you want to upload. This is a `Blob`, typically
2480
2520
The `uploadFile` function provides various options, including:
2481
2521
2482
2522
* `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.
2484
2524
* `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.
2485
2525
* `encoding`: The type of encoding for the file. For example, `identity` (raw) or `gzip`.
2486
2526
@@ -2496,35 +2536,9 @@ The function returns the uploaded asset key as an object with the following fiel
2496
2536
* `name`: The name of the asset (typically the filename). Example: `myimage.jpg`.
2497
2537
* `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>`.
2498
2538
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
-
2525
2539
---
2526
2540
2527
-
## Upload blob
2541
+
### Upload blob
2528
2542
2529
2543
The `uploadBlob` function works like ([`uploadFile`](#upload-file)) but does **not** infer the filename from the data. You must explicitly provide the `filename`.
2530
2544
@@ -2536,17 +2550,17 @@ This is useful when uploading raw binary data that wasn't selected via a file in
2536
2550
2537
2551
---
2538
2552
2539
-
## Protected assets
2553
+
### Protected asset
2540
2554
2541
2555
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".
2542
2556
2543
-
Juno achieves this by using an optional `token` query parameter.
2557
+
Juno achieves this by using an optional access `token` query parameter.
2544
2558
2545
2559
```
2546
2560
import { uploadFile } from "@junobuild/core";import { nanoid } from "nanoid";const result = await uploadFile({ data, collection: "images", token: nanoid()});
2547
2561
```
2548
2562
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)".
Copy file name to clipboardExpand all lines: docs/build/storage/development.mdx
+48-34Lines changed: 48 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,49 @@ import ClientSide from "../components/client-side.mdx";
8
8
9
9
---
10
10
11
-
## Upload file
11
+
## Concepts
12
12
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
14
54
15
55
To upload a file, use the following code:
16
56
@@ -30,7 +70,7 @@ The `data` parameter is the file you want to upload. This is a `Blob`, typically
30
70
The `uploadFile` function provides various options, including:
31
71
32
72
-`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.
34
74
-`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.
35
75
-`encoding`: The type of encoding for the file. For example, `identity` (raw) or `gzip`.
36
76
@@ -48,35 +88,9 @@ The function returns the uploaded asset key as an object with the following fiel
48
88
-`name`: The name of the asset (typically the filename). Example: `myimage.jpg`.
49
89
-`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>`.
50
90
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
-
77
91
---
78
92
79
-
## Upload blob
93
+
###Upload blob
80
94
81
95
The `uploadBlob` function works like [`uploadFile`](#upload-file) but does **not** infer the filename from the data.
82
96
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
95
109
96
110
---
97
111
98
-
## Protected assets
112
+
###Protected asset
99
113
100
114
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".
101
115
102
-
Juno achieves this by using an optional `token` query parameter.
116
+
Juno achieves this by using an optional access `token` query parameter.
103
117
104
118
```typescript
105
119
import { uploadFile } from"@junobuild/core";
@@ -112,7 +126,7 @@ const result = await uploadFile({
112
126
});
113
127
```
114
128
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".
116
130
117
131
---
118
132
@@ -320,7 +334,7 @@ const url = downloadUrl({
320
334
321
335
-**`assetKey`** (required)
322
336
-**`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.
324
338
325
339
-**`satellite`** (optional)
326
340
Required only in Node.js environments to specify which Satellite to use.
0 commit comments