Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skelpo/media-manager
A Vapor micro-service for resource storage
https://github.com/skelpo/media-manager
Last synced: 2 months ago
JSON representation
A Vapor micro-service for resource storage
- Host: GitHub
- URL: https://github.com/skelpo/media-manager
- Owner: skelpo
- License: mit
- Created: 2018-10-15T13:28:38.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-12T14:19:37.000Z (over 5 years ago)
- Last Synced: 2024-08-02T00:22:27.356Z (6 months ago)
- Language: Swift
- Homepage:
- Size: 59.6 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-Swift-Packages - media-manager - A Vapor micro-service for resource storage. (Storage)
README
# MediaManager
MediaManager is a micro-service written in Vapor, a server-side Swift framework. It works as an interface for media storage APIs such as Amazon S3 and Google Cloud Storage.
**Note:** MediaManager has Amazon S3 implemented by default. This can be removed if desired.
## Setup
After forking and cloning the repo, you can configure the various services used for storing resources. MediaManager already has Amazon S3 configured, so you can follow it, but here is an outline of what you need to do:
1. Install the storage client package for the service you wish to use. A list of available services can be found [here](#storage-services).
2. For cleanness sake, create a new file in the `Sources/App/Configuration` directory for the service you are using.
3. Add a function to your new file that will take in an `inout Services` and `StorageControllerCache` instances.
4. In the function you create, register the required services used by the storage service. Then add the storage service itself to the cache:```swift
cache.register(storage: Storage.self, slug: "storage")
```
Note: The slug value will be used to construct a controller's routes.5. In the `configuration.swift` file, add a call to your function, passing in the `Services` and `StorageControllerCache` instance.
```swift
let cache = StorageControllerCache()
try storage(&services, cache: cache) // <== Add line
services.register(cache)
```
That's it! The storage service is now available through the MediaManager API.## Storage Services
- [Amazon S3](https://github.com/skelpo/S3Storage)
- [Google Cloud Storage](https://github.com/skelpo/GoogleCloudStorage)
- The local file system comes by default.## API
The routes for the MediaManager are all under the `/*/media-manager` path. Each service is registered under the slug that it configured with, `/*/media-manager/s3` for example.
Each service has 4 routes:
- `POST /*/media-manager//`
Stores the new file under the service in the URL.
| Parameter | Description |
|------------|----------------------------------------------|
| `filename` | The relative directory and name for the file |
| `data` | The contents of the file |
- `GET /*/media-manager//...`
Fetches the contents of a file under the given directory and filename in the
URL suffix.- `PUT /*/media-manager//...`
Replaces the contents of a file under the given directory and filename in
the URL suffix.
| Parameter | Description |
|-----------|-------------------------------|
| `data` | The new contents of the file |- `DELETE /*/media-manager//...`
Deletes the file
## LICENSE
The MediaManager service is under the [MIT license agreement](https://github.com/skelpo/media-manager/blob/master/LICENSE).