Skip to content

Commit d6dff77

Browse files
committed
return file url from a client
1 parent 1397800 commit d6dff77

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

Sources/S3/Extensions/S3+Get.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ import Vapor
1212
// Helper S3 extension for loading (getting) files by their URL/path
1313
public extension S3 {
1414

15+
// MARK: URL
16+
17+
/// File URL
18+
public func url(fileInfo file: LocationConvertible, on container: Container) throws -> URL {
19+
let builder = urlBuilder(for: container)
20+
let url = try builder.url(file: file)
21+
return url
22+
}
23+
1524
// MARK: Get
1625

1726
/// Retrieve file data from S3

Sources/S3/Protocols/S3Client.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ public protocol S3Client: Service {
6666
/// Upload file to S3
6767
func put(string: String, mime: MediaType, destination: String, bucket: String?, access: AccessControlList, on: Container) throws -> Future<File.Response>
6868

69+
/// File URL
70+
func url(fileInfo file: LocationConvertible, on container: Container) throws -> URL
71+
6972
/// Retrieve file data from S3
7073
func get(fileInfo file: LocationConvertible, on container: Container) throws -> Future<File.Info>
7174

Sources/S3/S3.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import HTTP
1313

1414

1515
/// Main S3 class
16-
public class S3: S3Client {
16+
public class S3: S3Client {
1717

1818
/// Error messages
1919
public enum Error: Swift.Error {

0 commit comments

Comments
 (0)