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
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/03-Customization/02-customFieldRendering.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -239,6 +239,9 @@ Sometimes a custom editor needs to update not only its own field, but also other
239
239
240
240
For this, custom `edit`/`create` components can emit an `update:recordFieldValue` event with the payload `{ fieldName, fieldValue }`. AdminForth will update the corresponding field in the record.
241
241
242
+
> If you emit `update:recordFieldValue` to modify a field which is hidden by `showIn.create:false` / `showIn.edit:false`, the backend will reject the request by default.
243
+
> To allow this, set the target column config to `allowModifyWhenNotShowInCreate:true` and/or `allowModifyWhenNotShowInEdit:true`.
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/03-Customization/04-hooks.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ When user opens edit page, AdminForth makes a request to the backend to get the
44
44
45
45
Practically you can use `show.afterDatasourceResponse` to modify or add some data before it is displayed on the edit page.
46
46
47
-
For example [upload plugin](/docs/tutorial/Plugins/upload/) uses this hook to generate signed preview URL so user can see existing uploaded file preview in form, and at the same time database stores only original file path which might be not accessible without presigned URL.
47
+
For example [upload plugin](/docs/tutorial/Plugins/05-0-upload/) uses this hook to generate signed preview URL so user can see existing uploaded file preview in form, and at the same time database stores only original file path which might be not accessible without presigned URL.
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/03-Customization/12-security.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ Also you can add custom rules. For example to prevent popular words:
66
66
],
67
67
```
68
68
69
-
All rules defined in password column will be also delivered to [password reset plugin](../07-Plugins/07-email-password-reset.md) if you are using it to ensure that password reset will also respect same rules.
69
+
All rules defined in password column will be also delivered to [password reset plugin](../08-Plugins/07-email-password-reset.md) if you are using it to ensure that password reset will also respect same rules.
Copy file name to clipboardExpand all lines: adminforth/documentation/docs/tutorial/08-Plugins/05-0-upload.md
+6-68Lines changed: 6 additions & 68 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -305,73 +305,6 @@ new UploadPlugin({
305
305
> adminServeBaseUrl defines the public path prefix. If your AdminForth base URL is /admin, files will be accessible under /admin/static/source/<key>.
306
306
307
307
308
-
## API
309
-
310
-
### uploadFromBufferToNewRecord
311
-
312
-
In some cases you may want to upload a file directly from your backend (for example, a file generated by a background job or received from a webhook) without going through the browser. For this, the Upload plugin exposes the `uploadFromBufferToNewRecord` method.
313
-
314
-
You can code it as custom logic or you can simply reuse Upload plugin for this purpose as well.
315
-
316
-
This method uploads a file from a Node.js `Buffer`, automatically creates a record in the corresponding resource, and returns both the stored file path and a preview URL.
317
-
318
-
```tstitle="./some-backend-service.ts"
319
-
import { admin } from'./admin'; // your AdminForth instance
320
-
321
-
...
322
-
plugins: [
323
-
newUploadPlugin({
324
-
id: 'my_reports_plugin', // unique identifier for your plugin instance
- `uploadFromBufferToNewRecord` uses the configured storage adapter (S3, local, etc.) to store the file.
345
-
- It automatically creates a new record in the resource and stores the file path into the column defined by `pathColumnName`, together with any extra `recordAttributes` you pass.
346
-
- It returns an object `{ path, previewUrl }`, where `previewUrl` is the same URL that would be used for previews inside AdminForth.
347
-
348
-
> ⚠️ It is not recommended to upload large files from the backend using `uploadFromBuffer`, because the entire file must go through your server memory and network. For large uploads you should prefer frontend presigned uploads directly to storage. You can find an example of presigned upload flow using upload plugin in the Rich editor plugin source code (Rich editor actually uses Upload plugin to upload images in edited content).
349
-
350
-
351
-
### uploadFromBufferToExistingRecord
352
-
353
-
If you already have a record and just want to replace the file referenced in its `pathColumnName` field, you can use the `uploadFromBufferToExistingRecord` method. It uploads a file from a Node.js `Buffer`, updates the existing record, and returns the new file path and preview URL.
recordId: existingRecordId, // primary key of the record to update
360
-
filename: 'report.pdf',
361
-
contentType: 'application/pdf',
362
-
buffer, // Node.js Buffer with file content
363
-
adminUser, // current admin user or system user
364
-
extra: {}, // optional extra meta for your hooks / audit
365
-
});
366
-
```
367
-
368
-
- Uses the same storage adapter and validation rules as `uploadFromBufferToNewRecord` (file extension whitelist, `maxFileSize`, `filePath` callback, etc.).
369
-
- Does not create a new record – it only updates the existing one identified by `recordId`, replacing the value in `pathColumnName` with the new storage path.
370
-
- If the generated `filePath` would be the same as the current value in the record, it throws an error to help you avoid CDN/browser caching issues. To force a refresh, make sure your `filePath` callback produces a different key (for example, include a timestamp or random UUID).
371
-
372
-
> ⚠️ The same recommendation about large files applies here: avoid using `uploadFromBufferToExistingRecord` for very large uploads; prefer a presigned upload flow from the frontend instead.
373
-
374
-
375
308
376
309
## Image generation
377
310
@@ -726,4 +659,9 @@ And finally add this callback:
726
659
727
660
```
728
661
729
-
And now you can easily update avatar for each user
662
+
And now you can easily update avatar for each user
663
+
664
+
# API
665
+
666
+
If you wish to reuse Upload plugin for advanced tasks like upload custom files from frontend/backend
667
+
(including presigned frontend upload), see [05-1-upload-api.md](05-1-upload-api.md).
0 commit comments