Overview
Velt supports self-hosting your comments file attachments data:- Attachments can be stored on your own infrastructure, with only necessary identifiers on Velt servers.
- Velt Components automatically hydrate attachment data in the frontend by fetching from your configured data provider.
- This gives you full control over attachment data while maintaining the file attachment features.
How does it work?
When users upload or delete attachments:- The SDK uses your configured
AttachmentDataProviderto handle storage - Your data provider implements two key methods:
save: Stores the file and returns its URLdelete: Removes the file from storage
- The SDK first attempts to save/delete the file on your storage infrastructure
- If successful:
- The SDK updates Velt’s servers with minimal metadata
- The
PartialCommentobject is updated to reference the attachment including the attachment url, name and metadata. - When the comment is saved, this information is stored on your end.
- Velt servers only store necessary identifiers, not the actual files or URLs
- If the operation fails, no changes are made to Velt’s servers and the operation is retried if you have configured retries.
Implementation Approaches
You can implement attachment self-hosting using either of these approaches:- Endpoint based: Provide endpoint URLs and let the SDK handle HTTP requests
- Function based: Implement
saveanddeletemethods yourself
| Feature | Function based | Endpoint based |
|---|---|---|
| Best For | Complex setups requiring middleware logic, dynamic headers, or transformation before sending | Standard REST APIs where you just need to pass the request “as-is” to the backend |
| Implementation | You write the fetch() or axios code | You provide the url string and headers object |
| Flexibility | High | Medium |
| Speed | Medium | High |
Endpoint based DataProvider
Instead of implementing custom methods, you can configure endpoints directly and let the SDK handle HTTP requests.Unlike comments and reactions, attachment upload uses
multipart/form-data format to avoid base64 conversion overhead. The browser automatically manages the Content-Type header with the proper boundary parameter.saveConfig
Config-based endpoint for saving attachments. The SDK automatically makes HTTP POST requests with multipart/form-data.- Type:
ResolverEndpointConfig - Request format:
multipart/form-datawith two fields:file: File object (binary)request: JSON string containingSaveAttachmentResolverRequest
- Response format:
ResolverResponse<SaveAttachmentResolverData>
- React / Next.js
- Other Frameworks
- Backend Endpoint Example (S3)
deleteConfig
Config-based endpoint for deleting attachments. The SDK automatically makes HTTP POST requests with the request body.- Type:
ResolverEndpointConfig - Request body format:
DeleteAttachmentResolverRequest - Response format:
ResolverResponse<undefined>
- React / Next.js
- Other Frameworks
- Backend Endpoint Example (S3)
Endpoint based Complete Example
- React / Next.js
- Other Frameworks
Function based DataProvider
Implement custom methods to handle data operations yourself.save
Save attachments to your storage backend. Return the url with a success or error response. On error we will retry.- Frontend Example
- Backend Endpoint Example (S3)
delete
Delete attachments from your storage backend. Return a success or error response. On error we will retry.- Frontend Example
- Backend Endpoint Example (S3)
config
Configuration for the attachment data provider.- Type:
ResolverConfig. Relevant properties:resolveTimeout: Timeout duration (in milliseconds) for resolver operationssaveRetryConfig:RetryConfig. Configure retry behavior for save operations.deleteRetryConfig:RetryConfig. Configure retry behavior for delete operations.additionalFields:string[]. Specify additional fields from the attachment object to include in the resolver request payloads sent to your backend. By default, only core content fields are sent. Use this to request extra fields you need (e.g.,mimeType,size).
Function based Complete Example
- React / Next.js
- Other Frameworks
Sample Data
- Comment annotation stored on your database
- Attachment object stored on your database
- Stored on Velt servers
Debugging
You can subscribe todataProvider events to monitor and debug save and delete operations.
You can also use the Velt Chrome DevTools extension to inspect and debug your Velt implementation.
- React / Next.js
- Other Frameworks

