diff --git a/Sources/S3/Extensions/S3+Delete.swift b/Sources/S3/Extensions/S3+Delete.swift index 12d193b..bc899c0 100644 --- a/Sources/S3/Extensions/S3+Delete.swift +++ b/Sources/S3/Extensions/S3+Delete.swift @@ -15,7 +15,7 @@ public extension S3 { // MARK: Delete /// Delete file from S3 - public func delete(file: LocationConvertible, headers: [String: String] = [:], on container: Container) throws -> Future { + public func delete(file: LocationConvertible, headers: [String: String], on container: Container) throws -> Future { let url = try self.url(file: file, on: container) let headers = try signer.headers(for: .DELETE, urlString: url.absoluteString, headers: headers, payload: .none) return try make(request: url, method: .DELETE, headers: headers, data: "".convertToData(), on: container).map(to: Void.self) { response in diff --git a/Sources/S3/Extensions/S3+Get.swift b/Sources/S3/Extensions/S3+Get.swift index 1acfba3..0f39bfd 100644 --- a/Sources/S3/Extensions/S3+Get.swift +++ b/Sources/S3/Extensions/S3+Get.swift @@ -15,7 +15,7 @@ public extension S3 { // MARK: Get /// Retrieve file data from S3 - public func get(file: LocationConvertible, headers: [String: String] = [:], on container: Container) throws -> Future { + public func get(file: LocationConvertible, headers: [String: String], on container: Container) throws -> Future { let url = try self.url(file: file, on: container) let headers = try signer.headers(for: .GET, urlString: url.absoluteString, headers: headers, payload: .none) return try make(request: url, method: .GET, headers: headers, on: container).map(to: File.Response.self) { response in diff --git a/Sources/S3/Extensions/S3+ObjectInfo.swift b/Sources/S3/Extensions/S3+ObjectInfo.swift index 7878ef4..664de80 100644 --- a/Sources/S3/Extensions/S3+ObjectInfo.swift +++ b/Sources/S3/Extensions/S3+ObjectInfo.swift @@ -17,7 +17,7 @@ public extension S3 { /// Get acl file information (ACL) /// https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGETacl.html - public func get(acl file: LocationConvertible, headers: [String: String] = [:], on container: Container) throws -> Future { + public func get(acl file: LocationConvertible, headers: [String: String], on container: Container) throws -> Future { fatalError("Not implemented") } @@ -29,7 +29,7 @@ public extension S3 { /// Get file information (HEAD) /// https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectHEAD.html - public func get(fileInfo file: LocationConvertible, headers: [String: String] = [:], on container: Container) throws -> Future { + public func get(fileInfo file: LocationConvertible, headers: [String: String], on container: Container) throws -> Future { let url = try self.url(file: file, on: container) let headers = try signer.headers(for: .HEAD, urlString: url.absoluteString, headers: headers, payload: .none) return try make(request: url, method: .HEAD, headers: headers, data: "".convertToData(), on: container).map(to: File.Info.self) { response in diff --git a/Sources/S3/Extensions/S3+Put.swift b/Sources/S3/Extensions/S3+Put.swift index a0a66e6..c5c815a 100755 --- a/Sources/S3/Extensions/S3+Put.swift +++ b/Sources/S3/Extensions/S3+Put.swift @@ -16,7 +16,7 @@ public extension S3 { // MARK: Upload /// Upload file to S3 - public func put(file: File.Upload, headers: [String: String] = [:], on container: Container) throws -> EventLoopFuture { + public func put(file: File.Upload, headers: [String: String], on container: Container) throws -> EventLoopFuture { let url = try self.url(file: file, on: container) var awsHeaders: [String: String] = headers @@ -37,6 +37,11 @@ public extension S3 { } } + /// Upload file to S3 + public func put(file: File.Upload, on container: Container) throws -> EventLoopFuture { + return try put(file: file, headers: [:], on: container) + } + /// Upload file by it's URL to S3 public func put(file url: URL, destination: String, access: AccessControlList = .privateAccess, on container: Container) throws -> Future { let data: Data = try Data(contentsOf: url) diff --git a/Sources/S3/Protocols/S3Client.swift b/Sources/S3/Protocols/S3Client.swift index d871efa..3dcc649 100644 --- a/Sources/S3/Protocols/S3Client.swift +++ b/Sources/S3/Protocols/S3Client.swift @@ -33,6 +33,9 @@ public protocol S3Client: Service { /// Get list of objects func list(bucket: String, region: Region?, headers: [String: String], on container: Container) throws -> Future + /// Upload file to S3 + func put(file: File.Upload, on container: Container) throws -> EventLoopFuture + /// Upload file to S3 func put(file: File.Upload, headers: [String: String], on: Container) throws -> EventLoopFuture