iOS + Transloadit
Create uploads from iOS using a Template, TransloaditKit 3.5.0, and your app’s authenticated backend signing integration.
Executable recipe
Build the integration
This Swift helper creates an Assembly from one Template, queues a local file for upload, and polls its status. Your app supplies the authenticated signing integration described in the TransloaditKit guide.
- Install TransloaditKit exactly 3.5.0 with Swift Package Manager or CocoaPods. Swift Package Manager pins TUSKit to 3.6.0; keep the resolved dependency versions with your project.
- Create a server-owned Template with Step overrides disabled and require Signature Authentication. Configure the backend to allow only the intended workflow, following the TransloaditKit signing and usage guide.
- Replace the Auth Key, Template ID, and local file path placeholders, then call createAssembly with your app’s synchronous SignatureGenerator and handlers for completion and statusChanged.
- Call createAssembly off the main thread, retain the returned Transloadit client for the operation, and dispatch UI updates to the main queue. Handle failures in both callbacks.
Upload.swift
// Swift Package Manager:
// .package(url: "https://github.com/transloadit/TransloaditKit", exact: "3.5.0")
// Or CocoaPods: pod 'Transloadit', '3.5.0'
// Pin its dependency too: pod 'TUSKit', '3.6.0'
import Foundation
#if canImport(TransloaditKit)
import TransloaditKit
#else
import Transloadit
#endif
// TransloaditKit 3.5.0. Supply your app’s authenticated signing integration.
// Its backend must authorize params, expiry, processing and destination policy,
// then sign the exact original UTF-8 bytes. Do not reserialize them.
// The signing completion is nonescaping: call it synchronously exactly once
// before the signature generator returns, including denial and timeout.
// Use synchronous transport with a finite timeout, off the main thread.
// The SDK fixes a 24-hour expiry; use backend creation if policy requires less.
// Retain the returned client for the operation’s lifetime.
// Signing guide: https://transloadit.com/docs/sdks/transloaditkit/#user-content-transloaditkit-usage
func createAssembly(
signatureGenerator: @escaping SignatureGenerator,
configuration: URLSessionConfiguration = .default,
completion: @escaping (Result<Assembly, TransloaditError>) -> Void,
statusChanged: @escaping (Result<AssemblyStatus, TransloaditError>) -> Void
) -> Transloadit {
let transloadit = Transloadit(
apiKey: "YOUR_TRANSLOADIT_KEY",
sessionConfiguration: configuration,
signatureGenerator: signatureGenerator
)
// Replace these paths with local file URLs from your app.
let filesToUpload: [URL] = [
URL(fileURLWithPath: "/path/to/file.jpg"),
]
transloadit.createAssembly(templateId: "YOUR_TRANSLOADIT_TEMPLATE_ID", andUpload: filesToUpload, completion: completion)
.pollAssemblyStatus(completion: statusChanged)
return transloadit
}
Authentication
- Pass the public Auth Key and your app’s authenticated SignatureGenerator to the helper. Keep the Auth Secret on the backend and require Signature Authentication for the Workspace or Template.
- The backend must authenticate the user and authorize the exact Auth Key, Template, fields, processing, destinations, and expiry before signing the original UTF-8 params bytes. Reject extra Steps and unknown options; matching template_id alone is insufficient.
- TransloaditKit 3.5.0 uses a nonescaping signing completion. Call it exactly once before the SignatureGenerator returns, including denial and timeout, using synchronous transport with a finite timeout off the main thread.
Limitations and operational notes
- The SDK fixes auth.expires at 24 hours and the signing callback cannot replace the params. If your policy requires a shorter expiry, reject the request and use backend Assembly creation.
- This helper covers one Template and local files. TransloaditKit 3.5.0 cannot combine a Template with Step overrides or set arbitrary Assembly and auth options; use backend Assembly creation when those controls are required.
- The create callback means the Assembly exists and uploads were scheduled; it does not mean file upload or processing has finished.
- The SDK’s expected file count is outside signed params and is not an authorization limit. Enforce quotas and file restrictions through the server-owned workflow; use backend Assembly creation if the Template cannot enforce your requirements.
- The helper requires your app’s login and signing transport. Background scheduling, resumability, lifecycle handling, and file access need integration and testing on your target devices.
More integrations