Skip to content

Commit

Permalink
Inject URLSession in EventLoggingNetworkService
Browse files Browse the repository at this point in the history
  • Loading branch information
jkmassel committed Mar 25, 2020
1 parent 4f20dc6 commit fac0f65
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Automattic-Tracks-iOS/Services/EventLoggingNetworkService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ typealias NetworkResultCallback = (Result<Data?, Error>) -> Void

open class EventLoggingNetworkService {


private let urlSession: URLSession

init(urlSession: URLSession = URLSession.shared) {
self.urlSession = urlSession
}

func uploadFile(request: URLRequest, fileURL: URL, completion: @escaping NetworkResultCallback) {
URLSession.shared
.uploadTask(with: request, fromFile: fileURL, completionHandler: { data, response, error in
urlSession.uploadTask(with: request, fromFile: fileURL, completionHandler: { data, response, error in

if let error = error {
completion(.failure(error))
Expand Down

0 comments on commit fac0f65

Please sign in to comment.