Swift API Client for Upload & Management, and Uploader UI
Swift integration handles uploads and file operations by wrapping Uploadcare Upload API and REST API. This comprehensive API client lets you use most of the Uploadcare features from within your Android app. It also includes a native uploading widget. Builds are available for iOS, iPadOS, tvOS, Linux and macOS.
Check out a swift demo app that we created as a showcase for various usage scenarios and tasks that you can resolve.
Features
Uploading (Upload API):
- Upload files from a file, URL, and cloud sources (up to 5 TB)
- Multipart uploading for large files
- Uploading network to speed uploading jobs (like CDN)
File uploading widget:
- Upload files from a local disk, camera, and cloud sources
- Track, pause and continue multipart uploading
- Background uploading
- Bulk file uploading
File management (REST API):
- Get file info and perform various operations (store/delete/copy) with them
- Work with groups of files
- Get info about account project
- Manage webhooks
- Convert documents
- Encode and transform videos
Image processing (URL API):
- Compression
- Geometry
- Colors
- Definition
- Image and text overlays
- Rotations
- Recognition
- File info
- Proxy (fetch)
Security features:
- Secure authentication
- Secure uploads (signed uploads)
- Secure delivery (signed URLs)
- Secure webhooks (signing secret)
Installation
Swift Package Manager
To use a stable version, add a dependency to your Package.swift
file:
If you want to try the current dev version, change the dependency to:
To add from Xcode select File -> Swift Packages -> Add Package Dependency and enter the repository URL:
https://github.com/uploadcare/uploadcare-swift
Or you can add it in Xcode to the packages list using that URL: https://github.com/uploadcare/uploadcare-swift
(select master branch).
Carthage
To use a stable version, add a dependency to your Cartfile:
To use the current dev version:
Cocoapods
To use a stable version, add a dependency to your Podfile:
To use current dev version:
Initialization
Create your project in Uploadcare Dashboard and copy its API keys from there.
Upload API requires only a public key, while REST API requires both public and secret keys:
You can create more Uploadcare objects if you need to work with multiple projects in your Uploadcare account:
Keep in mind that since Uploadcare is not a singleton. You should store a strong reference (as an instance variable, for example) to your Uploadcare object or it will get deallocated.
Using Upload API
Check the Upload API documentation to see all available methods.
Each method has an implementation with a Result
completion handler and has
an alternative async
implementation to use with Swift concurrency.
Example of uploads:
It is possible to perform uploads in the background. But implementation is platform-specific. This lib doesn’t provide a default implementation. You can find an example for the iOS in our Demo app. See FilesListStore.swift.
Using REST API
Refer to the REST API documentation for all methods.
Each method has an implementation with a Result
completion handler
and has an alternative async
implementation to use with Swift concurrency.
Example of getting list of files:
Get next page:
Get previous page:
Full documentation
Read the full documentation on GitHub.
Demo app
Check the demo app for usage examples:
- List of files
- List of groups
- File info
- File upload (both direct and multipart, including upload in background)
- Multiple file upload
- Pause and continue multipart uploading
- Project info
Related guides
- Integration with Android