files-sdk
A Rust SDK for the Files.com API.
Note: This is an unofficial, community-maintained library and is not supported by Files.com. For official SDKs, see the Files.com Developer Documentation.
About Files.com
Files.com is a cloud storage and file transfer platform. This SDK provides access to the Files.com REST API
Installation
Add to your Cargo.toml
:
[]
= "0.3"
API Stability
Current Status (v0.3.x)
This SDK is pre-1.0 and under active development. While we strive for stability, breaking changes may occur in minor versions (0.x releases) as we refine the API based on real-world usage.
Stability Tiers
Component | Stability | Notes |
---|---|---|
Core Client | Stable | FilesClient , builder pattern, basic HTTP methods |
Error Types | Stable | FilesError variants and helpers |
File Operations | Stable | Upload, download, streaming APIs |
Resource Handlers | Beta | Feature-complete but may see refinements |
Advanced Features | Experimental | Rate limiting, retry logic - stabilizing |
Versioning
We follow Semantic Versioning:
- Patch (0.3.x): Bug fixes, documentation, non-breaking additions
- Minor (0.x.0): New features, may include breaking changes (per semver spec for 0.x)
- Major (1.0.0+): Indicates API stability commitment; breaking changes only in major versions
Note: Per semver, 0.x versions allow breaking changes in minor releases. We use this flexibility to refine the API based on real-world usage.
Minimum Supported Rust Version (MSRV)
- Current MSRV: Rust 1.85.0 (required for edition 2024)
- Policy: MSRV updates only in minor releases (0.x.0)
- Target: Support latest stable and N-2 prior releases
Stabilization Roadmap
The SDK is production-ready with ongoing refinements. We follow semver: breaking changes in minor releases (0.x) until the API is battle-tested, then we'll lock it down.
Completed:
- ✅ 100% API coverage (90 resources, 288 endpoints)
- ✅ Comprehensive error handling
- ✅ Streaming upload/download
- ✅ Retry logic with exponential backoff
- ✅ Client-side rate limiting
- ✅ Property-based testing
- ✅ Integration test suite
Ongoing:
- Gathering production usage feedback
- Refining handler APIs based on real-world use
- Expanding documentation and examples
- Working toward Files.com team review/adoption
When will breaking changes stop? When the API proves stable through real usage (likely 6-12 months). We'll then lock the API and switch to 1.x semver (breaking changes only in major versions).
For Production Use
While pre-1.0, this SDK is suitable for production with these considerations:
✅ Recommended:
- Pin exact versions in
Cargo.toml
:files-sdk = "=0.3.x"
- Test thoroughly before upgrading minor versions
- Review changelogs for breaking changes
⚠️ Be Aware:
- Handler method signatures may change
- New error variants may be added
- Some advanced features are stabilizing
📝 Feedback Welcome: Please open issues for any API pain points or suggestions. Real-world usage drives our 1.0 stabilization efforts!
Quick Start
use ;
async
Examples
File Operations
use ;
use Path;
let client = builder.api_key.build?;
let handler = new;
// Upload with automatic parent directory creation
handler.upload_file_with_options.await?;
// Download file metadata (returns FileEntity with download_uri)
let file = handler.download_file.await?;
println!;
// Download actual file content as bytes
let content = handler.download_content.await?;
println!;
// Download directly to local file
handler.download_to_file.await?;
// Copy file
handler.copy_file.await?;
// Move file
handler.move_file.await?;
// Delete file
handler.delete_file.await?;
// Upload entire directory recursively
let uploaded = handler.upload_directory.await?;
println!;
// Upload directory with progress callback
handler.upload_directory_with_progress.await?;
User Management
use ;
let client = builder.api_key.build?;
let handler = new;
// List users with pagination
let = handler.list.await?;
// Get specific user
let user = handler.get.await?;
// Create user
let new_user = handler.create.await?;
// Update user
handler.update.await?;
File Sharing
use ;
let client = builder.api_key.build?;
let handler = new;
// Create share link
let bundle = handler.create.await?;
println!;
// List all bundles
let = handler.list.await?;
Automation
use ;
let client = builder.api_key.build?;
let handler = new;
// Create automation
let automation = handler.create.await?;
// List automations
let = handler.list.await?;
Pagination
The SDK provides three approaches to handle paginated results:
Manual Pagination
use ;
let client = builder.api_key.build?;
let handler = new;
// Get first page
let = handler.list_folder.await?;
// Get next page if available
if let Some = pagination.cursor_next
Auto-Pagination (Collect All)
use ;
let client = builder.api_key.build?;
let handler = new;
// Automatically fetch all pages
let all_files = handler.list_folder_all.await?;
println!;
Streaming Pagination (Memory-Efficient)
use ;
use StreamExt;
let client = builder.api_key.build?;
// Stream folder contents
let folder_handler = new;
let mut stream = folder_handler.list_stream;
while let Some = stream.next.await
// Or collect all at once
let stream = folder_handler.list_stream;
let all_files: = stream.try_collect.await?;
// Stream users
let user_handler = new;
let mut user_stream = user_handler.list_stream;
while let Some = user_stream.next.await
When to use each approach:
- Manual: Fine-grained control, show "Load More" UI
- Auto-pagination: Simple cases, small-to-medium result sets
- Streaming: Large result sets, memory-constrained environments, real-time processing
Error Handling
All errors include contextual information to help with debugging and recovery:
use ;
let client = builder.api_key.build?;
let handler = new;
match handler.download_content.await
Helper methods for error construction:
use FilesError;
// Create contextual errors
let err = not_found_resource;
let err = validation_failed;
let err = rate_limited;
Tracing (Optional)
Enable HTTP-level debugging:
[]
= { = "0.1", = ["tracing"] }
= "0.3"
use ;
async
RUST_LOG=files_sdk=debug
Tower Middleware
The SDK supports composable middleware through Tower, a library for building robust networking clients and servers. Tower provides retry logic, rate limiting, timeouts, tracing, and more through a composable middleware system.
Enabling Tower Support
Add the tower
feature to your Cargo.toml
:
[]
= { = "0.3", = ["tower"] }
Why Tower?
Instead of implementing custom middleware (retry, rate limiting, etc.) directly in the SDK, we provide tower compatibility so you can:
- ✅ Compose your own middleware stack using industry-standard patterns
- ✅ Use battle-tested crates like
tower-http
,governor
, etc. - ✅ Customize behavior exactly for your use case
- ✅ Share middleware across different HTTP clients in your application
Examples
Retry with Exponential Backoff
use FilesClient;
use ServiceBuilder;
use RetryLayer;
use ServerErrorsAsFailures;
let client = builder.api_key.build?;
let retrying_client = new
.layer
.service;
Rate Limiting
use FilesClient;
use ServiceBuilder;
use ;
use NonZeroU32;
let client = builder.api_key.build?;
// Create rate limiter (10 requests/second)
let quota = per_second;
let limiter = direct;
// Apply via custom tower layer
let rate_limited_client = new
.layer
.service;
Observability (Tracing)
use FilesClient;
use ServiceBuilder;
use TraceLayer;
let client = builder.api_key.build?;
let traced_client = new
.layer
.service;
// All requests are now automatically traced
Combining Multiple Middleware
use FilesClient;
use ServiceBuilder;
use ;
use Duration;
let client = builder.api_key.build?;
let production_client = new
.timeout
.layer
.layer
.service;
More Information
See the examples directory for complete working examples:
examples/tower_retry.rs
- Retry logic with exponential backoffexamples/tower_rate_limit.rs
- Token bucket rate limitingexamples/tower_observability.rs
- Request/response tracing and metrics
For more on Tower, see:
API Coverage
Module | Description |
---|---|
files:: |
File upload/download, folders, comments |
users:: |
Users, groups, permissions, API keys |
sharing:: |
Bundles, file requests, share groups, forms |
automation:: |
Automations, behaviors, webhooks |
admin:: |
Site settings, history, invoices, DNS, styles |
logs:: |
API logs, SFTP logs, audit trails, external events |
messages:: |
Notifications, message exports |
storage:: |
Projects, snapshots, locks |
security:: |
GPG keys, SFTP host keys |
as2:: |
AS2 stations, partners, messages |
integrations:: |
SIEM destinations |
developers:: |
Apps and API integrations |
Path Encoding & Special Characters
The SDK automatically handles special characters in file paths:
// These all work correctly - paths are automatically URL-encoded
handler.upload_file.await?; // spaces
handler.upload_file.await?; // brackets
handler.upload_file.await?; // unicode
handler.upload_file.await?; // special chars
Paths are encoded using percent-encoding (RFC 3986), ensuring compatibility with Files.com's API regardless of the characters used in file or folder names.
Error Types
All errors include optional contextual fields for better debugging:
Utility methods:
// Get HTTP status code
if let Some = error.status_code
// Check if error is retryable (429, 500, 502, 503, 504)
if error.is_retryable
// Get retry delay for rate limits
if let Some = error.retry_after
Testing
The SDK provides comprehensive testing examples to help you test code that uses Files.com without hitting the real API.
Running SDK Tests
# Unit tests
# Integration tests (requires FILES_API_KEY)
FILES_API_KEY=your_key
Testing Your Code
See examples/testing/
for complete examples of different testing approaches:
1. Trait-Based Mocking with mockall
Create mockable traits for your file operations:
use automock;
Run: cargo test --example mockall_example
2. Test Doubles (Hand-Written Fakes)
Build custom test doubles that track state:
use ;
Run: cargo test --example test_doubles_example
3. HTTP Mocking with wiremock
Test actual HTTP interactions with a mock server:
use ;
use ;
use FilesClient;
async
Run: cargo test --example wiremock_example
Which Approach to Use?
Approach | Best For | Pros | Cons |
---|---|---|---|
mockall | Unit tests, verifying method calls | Auto-generated mocks, expectation verification | Requires trait abstraction |
Test Doubles | Integration tests, state verification | No dependencies, full control | More code to maintain |
wiremock | HTTP-level testing, API contract testing | Tests real HTTP flow, verifies headers/body | Slower, more setup |
Development Dependencies
Add to your Cargo.toml
for testing:
[]
= "0.13" # For trait-based mocking
= "0.6" # For HTTP mocking (already included in SDK)
License
MIT OR Apache-2.0