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"
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
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
# Unit tests
# Mock tests
# Integration tests (requires FILES_API_KEY)
FILES_API_KEY=your_key
License
MIT OR Apache-2.0