Skip to content

Commit

Permalink
return file url from a client
Browse files Browse the repository at this point in the history
  • Loading branch information
rafiki270 committed May 26, 2018
1 parent 1397800 commit d6dff77
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Sources/S3/Extensions/S3+Get.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ import Vapor
// Helper S3 extension for loading (getting) files by their URL/path
public extension S3 {

// MARK: URL

/// File URL
public func url(fileInfo file: LocationConvertible, on container: Container) throws -> URL {
let builder = urlBuilder(for: container)
let url = try builder.url(file: file)
return url
}

// MARK: Get

/// Retrieve file data from S3
Expand Down
3 changes: 3 additions & 0 deletions Sources/S3/Protocols/S3Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public protocol S3Client: Service {
/// Upload file to S3
func put(string: String, mime: MediaType, destination: String, bucket: String?, access: AccessControlList, on: Container) throws -> Future<File.Response>

/// File URL
func url(fileInfo file: LocationConvertible, on container: Container) throws -> URL

/// Retrieve file data from S3
func get(fileInfo file: LocationConvertible, on container: Container) throws -> Future<File.Info>

Expand Down
2 changes: 1 addition & 1 deletion Sources/S3/S3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import HTTP


/// Main S3 class
public class S3: S3Client {
public class S3: S3Client {

/// Error messages
public enum Error: Swift.Error {
Expand Down

0 comments on commit d6dff77

Please sign in to comment.