Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2a9d5c9
feat: refactor entity file storage controller and enhance URL generat…
marioserrano09 May 15, 2026
2d4d13b
feat: update dependencies to version 26.5.0
marioserrano09 May 15, 2026
a2a4cef
feat: add utility methods to load request parameters and headers into…
marioserrano09 May 15, 2026
c573a8b
feat: update DownloadFileAction to improve file download handling and…
marioserrano09 May 15, 2026
834f56f
feat: add URL and thumbnail URL accessors to EntityFile for improved …
marioserrano09 May 15, 2026
245f259
feat: enhance EntityFileSecurityProvider with access check and token …
marioserrano09 May 15, 2026
396a4e1
feat: add export endpoint to EntityFileStorageController for entity f…
marioserrano09 May 15, 2026
b19a70a
feat: add export and upload endpoints to FilesApi for enhanced file m…
marioserrano09 May 16, 2026
41d606b
feat: update README to include upload methods and enhance file handli…
marioserrano09 May 16, 2026
54d1cb8
feat: add upload endpoints for multipart and Base64 file uploads in E…
marioserrano09 May 16, 2026
57c8cce
chore: bump version to 26.5.0 for multiple SDKs in package.json
marioserrano09 May 16, 2026
04e83a1
feat: add initial implementation of core services and configuration f…
marioserrano09 May 16, 2026
ec55a39
chore: update pnpm-workspace.yaml to disable sharp builds
marioserrano09 May 16, 2026
c09161f
feat: add shell tab-completion support for sfs CLI and enhance file m…
marioserrano09 May 16, 2026
7159c65
chore: downgrade springboot version from 4.0.6 to 4.0.5 in pom.xml
marioserrano09 May 16, 2026
e178871
feat: implement RemoteEntityFileStorage for handling files in a remot…
marioserrano09 May 16, 2026
d6c56fb
feat: enhance auth plugin with fastify-plugin and improve file upload…
marioserrano09 May 16, 2026
ce36263
fix: remove content type setting in RemoteEntityFileStorage for file …
marioserrano09 May 16, 2026
faa24d0
fix: update authIdentity decoration to use null value for compatibili…
marioserrano09 May 18, 2026
d80ed8c
feat: add comprehensive documentation for simple-file-server architec…
marioserrano09 May 18, 2026
1ecc6e1
feat: enhance RemoteEntityFileStorage to include SFS authentication i…
marioserrano09 May 18, 2026
1899160
fix: update thumbnail service to use 'contain' fit option for resizing
marioserrano09 May 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/backend/EXTENSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,16 @@ dynamia.entityfiles.s3.secret-key=${AWS_SECRET_KEY}
```

### When to Use Entity Files Extension
#### MinIO Storage
```properties
# MinIO storage
DEFAULT_STORAGE_ID=MinioStorage
MINIO_ENDPOINT=http://localhost:9000
MINIO_BUCKET=my-bucket
MINIO_REGION=us-east-1
MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY=${MINIO_SECRET_KEY}
```

- Attach documents to records
- Store user profiles or avatars
Expand Down
4 changes: 2 additions & 2 deletions examples/demo-zk-books/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.0.3</version>
<version>4.0.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -47,7 +47,7 @@
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyyMMdd</maven.build.timestamp.format>

<tools.version>26.4.0</tools.version>
<tools.version>26.5.0</tools.version>

</properties>

Expand Down
6 changes: 3 additions & 3 deletions extensions/dashboard/sources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.parent</artifactId>
<version>26.4.1</version>
<version>26.5.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand All @@ -38,12 +38,12 @@
<dependency>
<groupId>tools.dynamia</groupId>
<artifactId>tools.dynamia.zk</artifactId>
<version>26.4.1</version>
<version>26.5.0</version>
</dependency>
<dependency>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.saas.api</artifactId>
<version>26.4.1</version>
<version>26.5.0</version>
</dependency>
</dependencies>

Expand Down
6 changes: 3 additions & 3 deletions extensions/email-sms/sources/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<artifactId>tools.dynamia.modules.email.parent</artifactId>
<groupId>tools.dynamia.modules</groupId>
<version>26.4.1</version>
<version>26.5.0</version>
</parent>

<artifactId>tools.dynamia.modules.email</artifactId>
Expand All @@ -50,12 +50,12 @@
<dependency>
<groupId>tools.dynamia</groupId>
<artifactId>tools.dynamia.domain.jpa</artifactId>
<version>26.4.1</version>
<version>26.5.0</version>
</dependency>
<dependency>
<groupId>tools.dynamia</groupId>
<artifactId>tools.dynamia.templates</artifactId>
<version>26.4.1</version>
<version>26.5.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand Down
4 changes: 2 additions & 2 deletions extensions/email-sms/sources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.parent</artifactId>
<version>26.4.1</version>
<version>26.5.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -85,7 +85,7 @@
<dependency>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.saas.jpa</artifactId>
<version>26.4.1</version>
<version>26.5.0</version>
</dependency>


Expand Down
6 changes: 3 additions & 3 deletions extensions/email-sms/sources/ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>tools.dynamia.modules.email.parent</artifactId>
<groupId>tools.dynamia.modules</groupId>
<version>26.4.1</version>
<version>26.5.0</version>
</parent>

<name>DynamiaModules - Email UI</name>
Expand All @@ -34,12 +34,12 @@
<dependency>
<groupId>tools.dynamia</groupId>
<artifactId>tools.dynamia.zk</artifactId>
<version>26.4.1</version>
<version>26.5.0</version>
</dependency>
<dependency>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.email</artifactId>
<version>26.4.1</version>
<version>26.5.0</version>
</dependency>
<dependency>
<groupId>tools.dynamia.zk.addons</groupId>
Expand Down
11 changes: 11 additions & 0 deletions extensions/entity-files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,22 @@ metadata are store in the database in table `mod_entity_files` using JPA entity
</dependency>
```

#### MinIO Support
```xml
<dependency>
<groupId>tools.dynamia.modules</groupId>
<artifactId>tools.dynamia.modules.entityfiles.minio</artifactId>
<version>7.4.0</version>
</dependency>
```

### Gradle

```groovy
compile 'tools.dynamia.modules:tools.dynamia.modules.entityfiles:7.4.0'
compile 'tools.dynamia.modules:tools.dynamia.modules.entityfiles.ui:7.4.0'
compile 'tools.dynamia.modules:tools.dynamia.modules.entityfiles.s3:7.4.0'
compile 'tools.dynamia.modules:tools.dynamia.modules.entityfiles.minio:7.4.0'
```

## Usage
Expand Down Expand Up @@ -115,6 +125,7 @@ files.

- `LocalEntityFileStorage` is the default implementation and store files in local file system
- `S3EntityFileStorage` in module S3 can upload files to AWS S3 buckets
- `MinioEntityFileStorage` in module MinIO can upload files to MinIO buckets using the MinIO Java SDK

## License

Expand Down
72 changes: 64 additions & 8 deletions extensions/entity-files/packages/files-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

> TypeScript / JavaScript client SDK for the Dynamia Entity Files extension REST API.

`@dynamia-tools/files-sdk` provides a small, focused client to download files managed by the Entity Files extension of a Dynamia Platform backend. The package exposes a single API class, `FilesApi`, which delegates HTTP, authentication and error handling to the core `@dynamia-tools/sdk` `HttpClient`.
`@dynamia-tools/files-sdk` provides a small, focused client to download, inspect and upload files managed by the Entity Files extension of a Dynamia Platform backend. The package exposes a single API class, `FilesApi`, which delegates base URL handling to the core `@dynamia-tools/sdk` `HttpClient` and reuses the same authentication context for upload operations.

This README explains how to install the package, how to use `FilesApi` (recommended via `DynamiaClient`) and how to handle binary downloads in browser and Node.js environments.
This README explains how to install the package, how to use `FilesApi` (recommended via `DynamiaClient`) and how to handle downloads plus the new multipart / base64 upload flows.

---

Expand All @@ -13,6 +13,7 @@ This README explains how to install the package, how to use `FilesApi` (recommen
- [Installation](#installation)
- [Quick Start (recommended)](#quick-start-recommended)
- [API methods](#api-methods)
- [Upload examples](#upload-examples)
- [Browser example (download and show)](#browser-example-download-and-show)
- [Node.js example (save to disk)](#nodejs-example-save-to-disk)
- [Authentication & Errors](#authentication--errors)
Expand Down Expand Up @@ -54,27 +55,82 @@ const files = new FilesApi(client.http);
// Download a file as a Blob (browser)
const blob = await files.download('myfile.pdf', 'f9a3e8c2-...');

// Get file metadata and direct URL from the server
const metadata = await files.export('f9a3e8c2-...');

// Get a direct URL (no network call performed)
const url = files.getUrl('images/logo.png', 'f9a3e8c2-...');
const url = files.getUrl('myfile.pdf', 'f9a3e8c2-...');
console.log(url);
```

Notes:
- `FilesApi` methods are thin wrappers over the core `HttpClient` (`get`, `url`) implemented by `DynamiaClient`.
- The `download()` method calls `GET /storage/{file}?uuid={uuid}` and returns a `Blob` in browser environments; when running in Node.js the underlying fetch polyfill may provide an `ArrayBuffer`/`Buffer` which you should convert to a file.
- The `download()` method calls `GET /storage/{uuid}/{file}` and returns a `Blob` in browser environments; when running in Node.js the underlying fetch polyfill may provide an `ArrayBuffer`/`Buffer` which you should convert to a file.
- The upload methods call the new REST endpoints exposed by `EntityFileStorageController`: `POST /api/storage/upload` and `POST /api/storage/upload-base64`.

---

## API methods

The implementation in `src/api.ts` exposes two methods on `FilesApi`:
The implementation in `src/api.ts` exposes the following methods on `FilesApi`:

- `export(uuid: string): Promise<EntityFileExportResponse>`
- GET `/api/storage/{uuid}/export` — Returns server-side metadata such as `name`, `size`, `version` and `url`.
- `download(file: string, uuid: string): Promise<Blob>`
- GET `/storage/{file}?uuid={uuid}` — Downloads the file. The SDK returns parsed JSON for `application/json` responses and a `Blob` for other content types (binary).
- GET `/storage/{uuid}/{file}` — Downloads the file. The SDK returns parsed JSON for `application/json` responses and a `Blob` for other content types (binary).
- `getUrl(file: string, uuid: string): string`
- Returns a fully-qualified URL that points to `/storage/{file}` with the `uuid` query parameter. No HTTP request is made.
- Returns a fully-qualified URL that points to `/storage/{uuid}/{file}`. No HTTP request is made.
- `uploadMultipart(file: Blob | File, options?: MultipartUploadOptions): Promise<EntityFileUploadResponse>`
- POST `/api/storage/upload` — Uploads a file using multipart form data.
- `uploadBase64(request: Base64UploadRequest): Promise<EntityFileUploadResponse>`
- POST `/api/storage/upload-base64` — Uploads a file using JSON containing `base64` or `data` content.

Use `download()` when you need the file content programmatically (e.g., for preview or file save). Use `getUrl()` when you want to put a direct link in an `img` `src`, anchor `href`, or let the browser perform the download. Use `export()` when you need server-generated metadata or a pre-authorized URL. Use the upload methods when the frontend must create `EntityFile` records directly.

---

## Upload examples

### Multipart upload

```ts
const uploaded = await files.uploadMultipart(fileInput.files![0], {
className: 'com.example.crm.Customer',
entityId: 15,
description: 'Signed contract',
shared: false,
parentUuid: 'folder-uuid',
});

console.log(uploaded.uuid, uploaded.url);
```

### Base64 JSON upload

```ts
const uploaded = await files.uploadBase64({
fileName: 'avatar.png',
contentType: 'image/png',
base64: imageBase64,
className: 'com.example.crm.Customer',
entityId: '15',
shared: true,
});

console.log(uploaded.uuid, uploaded.valid);
```

Both upload methods support these optional fields:

- `className`
- `entityId`
- `description`
- `shared`
- `subfolder`
- `storedFileName`
- `parentUuid`

Use `download()` when you need the file content programmatically (e.g., for preview or file save). Use `getUrl()` when you want to put a direct link in an `img` `src`, anchor `href`, or let the browser perform the download.
When `className` and `entityId` are omitted, the server creates a temporal file. When both are provided, the uploaded file is attached to the referenced entity.

---

Expand Down
2 changes: 1 addition & 1 deletion extensions/entity-files/packages/files-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dynamia-tools/files-sdk",
"version": "26.4.1",
"version": "26.5.0",
"website": "https://dynamia.tools",
"description": "TypeScript/JavaScript client SDK for the Dynamia Entity Files extension REST API",
"keywords": [
Expand Down
Loading
Loading