@bluealba/pae-ui-react-core 4.5.1 → 4.6.0-feature-generalist-file-storage-a-398

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -149,6 +149,39 @@ this event and its version and the associated Application (if the module has one
149
149
 
150
150
  Alternatively you can also use `useTrackEvents()` (plural) hook to publish more than one event in a single call.
151
151
 
152
+ ### useFileStorage
153
+
154
+ Imperative SDK client for the platform's File Storage API. Provides authenticated methods to upload, download, preview, update metadata, and delete files. Acts as a facade over the gateway's `/files` endpoints — you do not need to manage tokens, XHR configuration, or blob lifecycle manually.
155
+
156
+ ```typescript jsx
157
+ import { useFileStorage } from '@bluealba/pae-ui-react-core';
158
+
159
+ const { isEnabled, upload, download, getPreviewUrl, updateMetadata, remove } = useFileStorage();
160
+
161
+ // Check availability before rendering file UI
162
+ if (!isEnabled) return null;
163
+
164
+ // Upload a file with optional progress tracking
165
+ const result = await upload(file, {
166
+ isPublic: false,
167
+ description: 'Q1 report',
168
+ metadata: { project: 'alpha' },
169
+ onProgress: (percent) => console.log(`${percent}%`),
170
+ });
171
+ console.log('Uploaded file id:', result.id);
172
+
173
+ // Trigger a save-to-disk download
174
+ await download(result.id);
175
+ ```
176
+
177
+ **`isEnabled`** is `false` when `FILE_STORAGE_DRIVER` is not configured on the gateway. All methods reject immediately with `"File storage is disabled on this platform"` in that case — always check `isEnabled` before rendering file controls.
178
+
179
+ **`getPreviewUrl(id)`** returns a `URL.createObjectURL(blob)` string. The caller is responsible for revoking it via `URL.revokeObjectURL(url)` — typically in a `useEffect` cleanup — to avoid memory leaks.
180
+
181
+ Requires RBAC operations `files::read` (download, preview) and `files::manage` (upload, update, delete) assigned to the user's role.
182
+
183
+ For a complete usage guide including abort support, the preview pattern with proper cleanup, and error handling see the **[Using File Storage in React](apps/pae-documentation/docs/guides/using-file-storage-in-react.mdx)** guide.
184
+
152
185
  ## Authorization
153
186
 
154
187
  In order to render a piece of JSX conditionally based on authorization there are two ways to do this.