Add InsForge to your Swift Package Manager dependencies:
Enable Logging (Optional)
For debugging, you can configure the SDK log level and destination:
Log Levels:
| Level | Description |
|---|
.trace | Most verbose, includes all internal details |
.debug | Detailed information for debugging |
.info | General operational information (default) |
.warning | Warnings that don’t prevent operation |
.error | Errors that affect functionality |
.critical | Critical failures |
Log Destinations:
| Destination | Description |
|---|
.console | Standard output (print) |
.osLog | Apple’s unified logging system (recommended for iOS/macOS) |
.none | Disable logging |
.custom | Provide your own LogHandler factory |
Use .info or .error in production to avoid exposing sensitive data in logs.
from()
获取存储桶的文件 API 引用。
存储桶操作
createBucket()
创建新的存储桶。
listBuckets()
列出所有存储桶名称。
updateBucket()
更新存储桶的可见性。
deleteBucket()
删除存储桶。
upload()
上传文件到存储桶。
path (String) - 文件的对象键/路径
data (Data) - 要上传的文件数据
options (FileOptions, optional) - 上传选项,包括 contentType
download()
下载文件为数据。
list()
列出存储桶中的文件。
options (ListOptions, optional) - 选项,包括前缀、限制、偏移
delete()
从存储删除文件。
getPublicURL()
获取公共存储桶中文件的公共 URL。
上传策略
获取大文件的上传策略(直接或预签名 URL)。
getUploadStrategy()
confirmUpload()
在上传到 S3 后确认预签名上传。
下载策略
获取私有文件的下载策略(直接或预签名 URL)。
getDownloadStrategy()
选项参考
FileOptions
文件上传操作的选项。
BucketOptions
存储桶创建/更新的选项。
ListOptions
列出文件的选项。
StoredFile 模型
存储操作的响应模型。