Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skelpo/Storage
An interface for storing files with any API.
https://github.com/skelpo/Storage
Last synced: 2 months ago
JSON representation
An interface for storing files with any API.
- Host: GitHub
- URL: https://github.com/skelpo/Storage
- Owner: skelpo
- License: mit
- Created: 2018-12-12T22:30:40.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-01T12:13:25.000Z (over 5 years ago)
- Last Synced: 2024-10-15T00:09:42.449Z (3 months ago)
- Language: Swift
- Size: 495 KB
- Stars: 7
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-Swift-Packages - Storage - An interface for storing files with any API. (Storage)
README
# Storage
Storage is a generic interface for resource storing APIs, such as Google Cloud Storage, Amazon S3, or your local file system.
## Installing
Add a package instance to your manifest's `dependencies` array with the [latest version](https://github.com/skelpo/Storage/releases/latest):
```swift
.package(url: "https://github.com/skelpo/Storage.git", from: "0.1.0")
```Then run `swift package update` and regenerate your Xcode project if you have one.
## API
### `Storage`
The Storage package is built around the `Storage` protocol which defines a type that can create, read, update, and delete files.
It requires 4 methods:
- `func store(file: File, at path: String?) -> EventLoopFuture`
- `func fetch(file: String) -> EventLoopFuture`
- `func write(file: String, with data: Data) -> EventLoopFuture`
- `func delete(file: String) -> EventLoopFuture`### `File`
A Swift type that represents file with a name `String` and the contents as `ByteBuffer`.
### `StorageError`
If any error occurs in the `Storage` methods, a `StorageError` is returned in the future. Use this error if you create your own `Storage` implementation.
### `LocalStorage`
A `Storage` implementation for interacting with files in your local file system. The `store` and `fetch` methods stream the file data, while the `delete` and `write` methods are run on the instance's event loop.
## Documentation
You can see the API documentation [here](http://www.skelpo.codes/Storage).
## License
This package is registered under the [MIT license agreement](https://github.com/skelpo/Storage/blob/master/LICENSE).