LocalStorage

1.0.0-beta.2

Storage driver using Local filesystem for Vapor 3
gperdomor/local-storage

What's New

1.0.0-beta.2

2018-05-11T02:07:33Z

Changes since Beta 1

  • General Improvements
  • Fix added compatibility with Linux

Swift Version Vapor Version Build Status codecov GitHub license

LocalStorage

Storage driver using Local filesystem for Vapor 3.

This package is based on StorageKit

Installation

Add this project to the Package.swift dependencies of your Vapor project:

  .package(url: "https://github.com/gperdomor/local-storage.git", from: "0.1.0")

Setup

After you've added the LocalStorage package to your project, setting the provider up in code is easy.

Service registration

First, register the LocalStorageProvider in your `configure.swift' file.

public func configure(
    _ config: inout Config,
    _ env: inout Environment,
    _ services: inout Services
) throws {
    /// Register providers first
    try services.register(LocalStorageProvider())

    // or whatever directory you want
    let rootDirectory = DirectoryConfig.detect().workDir

    // Add the adapter
    var adapters = AdapterConfig()
    adapters.add(adapter: try LocalAdapter(rootDirectory: URL(fileURLWithPath: "\(rootDirectory)Public/buckets"), create: true), as: .local)
    services.register(adapters)
}

Use

struct BucketRequest: Content {
    let name: String
}

func create(_ req: Request, body: BucketRequest) throws -> Future<HTTPStatus> {
    let name = body.name

    return req.withStorage(to: AdapterIdentifier<LocalAdapter>.local) { storage in
        return try storage.create(bucket: name, on: req).transform(to: HTTPStatus.ok)
    }
}

Learn More

Credits

This package is developed and maintained by Gustavo Perdomo

License

LocalStorage is released under the MIT License.

Description

  • Swift Tools 4.0.0
View More Packages from this Author

Dependencies

Last updated: Thu Apr 09 2026 04:25:40 GMT-0900 (Hawaii-Aleutian Daylight Time)