Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #36 from valen90/feature/vapor-two
Browse files Browse the repository at this point in the history
Updated to Vapor 2
  • Loading branch information
steffendsommer authored May 18, 2017
2 parents aeb5f1d + aad7e34 commit c7c5d2f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 44 deletions.
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import PackageDescription
let package = Package(
name: "Storage",
dependencies: [
.Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1),
.Package(url: "https://github.com/nodes-vapor/data-uri.git", majorVersion: 0),
.Package(url: "https://github.com/nodes-vapor/aws.git", majorVersion: 0),
.Package(url: "https://github.com/vapor/vapor.git", Version(2,0,0, prereleaseIdentifiers: ["beta"])),
.Package(url: "https://github.com/nodes-vapor/data-uri.git", Version(1,0,0, prereleaseIdentifiers: ["beta"])),
.Package(url: "https://github.com/nodes-vapor/aws.git", Version(1,0,0, prereleaseIdentifiers: ["beta"])),
.Package(url: "https://github.com/manGoweb/MimeLib.git", majorVersion: 1)
]
)
9 changes: 5 additions & 4 deletions Sources/Storage/Provider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import enum AWSSignatureV4.Region

///A provider for configuring the `Storage` package.
public final class StorageProvider: Provider {

public static var repositoryName: String = "Storage"

public enum Error: Swift.Error {
case missingConfigurationFile
case unsupportedDriver(String)
Expand All @@ -14,10 +17,6 @@ public final class StorageProvider: Provider {
case unknownRegion(String)
}

public var provided: Providable {
return Providable()
}

public init(config: Config) throws {
guard let config = config["storage"] else {
throw Error.missingConfigurationFile
Expand All @@ -29,6 +28,8 @@ public final class StorageProvider: Provider {
}

public func boot(_ drop: Droplet) {}

public func boot(_ config: Config) throws {}

public func afterInit(_ drop: Droplet) {}

Expand Down
36 changes: 1 addition & 35 deletions Sources/Storage/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class Storage {
public enum Error: Swift.Error {
case missingNetworkDriver
case cdnBaseURLNotSet
case unsupportedMultipart(Multipart)
case missingFileName
}

Expand All @@ -36,39 +35,6 @@ public class Storage {
return try networkDriver.upload(entity: &entity)
}

/**
Uploads the given `Multipart` file.

- Parameters:
- multipart: The file to be uploaded.
- folder: The folder to save the file in.

- Returns: The path the file was uploaded to.
*/
@discardableResult
public static func upload(
multipart: Multipart,
folder: String? = nil
) throws -> String {
switch multipart {
case .file(let file):
guard let name = file.name else {
throw Error.missingFileName
}

return try upload(
bytes: file.data,
fileName: name,
fileExtension: nil,
mime: file.type,
folder: folder
)

default:
throw Error.unsupportedMultipart(multipart)
}
}

@discardableResult
public static func upload(
formData: Field,
Expand Down Expand Up @@ -105,7 +71,7 @@ public class Storage {
fileExtension: String? = nil,
folder: String? = nil
) throws -> String {
let response = try BasicClient.get(url)
let response = try EngineClient.factory.get(url)
var entity = FileEntity(
fileName: fileName,
fileExtension: fileExtension,
Expand Down
4 changes: 2 additions & 2 deletions Sources/Storage/Template.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ extension Template {
}
}

return try String(bytes: pathBytes)
return String(bytes: pathBytes)
}
}

Expand Down Expand Up @@ -215,7 +215,7 @@ extension Template {
current = next
}

let invalidAlias = try String(bytes: partial)
let invalidAlias = String(bytes: partial)
throw Error.invalidAlias(invalidAlias)
}

Expand Down

0 comments on commit c7c5d2f

Please sign in to comment.