Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PMHTTP.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Pod::Spec.new do |s|
s.watchos.deployment_target = "2.0"
s.tvos.deployment_target = "9.0"

s.swift_version = '4.0'
s.swift_version = '4.2'

s.source = { :git => "https://github.com/postmates/PMHTTP.git", :tag => "v#{s.version}" }
s.source_files = "Sources"
Expand Down
8 changes: 4 additions & 4 deletions PMHTTP.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.postmates.PMHTTP;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -610,7 +610,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.postmates.PMHTTP;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -625,7 +625,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.postmates.PMHTTPTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -639,7 +639,7 @@
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.postmates.PMHTTPTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
8 changes: 4 additions & 4 deletions Sources/PlatformSpecific.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import Foundation
/// - filename: The filename of the attachment. Optional.
public func addMultipartPNG(for image: UIImage, withName name: String, filename: String? = nil) {
self.addMultipartBody(using: { upload in
guard let data = UIImagePNGRepresentation(image) else { return }
guard let data = image.pngData() else { return }
upload.addMultipart(data: data, withName: name, mimeType: "image/png", filename: filename)
})
}
Expand All @@ -69,7 +69,7 @@ import Foundation
/// - filename: The filename of the attachment. Optional.
public func addMultipartJPEG(for image: UIImage, withCompressionQuality quality: CGFloat, name: String, filename: String? = nil) {
self.addMultipartBody(using: { upload in
guard let data = UIImageJPEGRepresentation(image, quality) else { return }
guard let data = image.jpegData(compressionQuality: quality) else { return }
upload.addMultipart(data: data, withName: name, mimeType: "image/jpeg", filename: filename)
})
}
Expand Down Expand Up @@ -387,12 +387,12 @@ import Foundation
else { return nil }
let imageProps = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, nil) as NSDictionary?
let exifOrientation = (imageProps?[kCGImagePropertyOrientation] as? NSNumber)?.intValue
let orientation = exifOrientation.map(UIImageOrientation.init(exifOrientation:)) ?? .up
let orientation = exifOrientation.map(UIImage.Orientation.init(exifOrientation:)) ?? .up
self.init(cgImage: cgImage, scale: scale, orientation: orientation)
}
}

private extension UIImageOrientation {
private extension UIImage.Orientation {
init(exifOrientation orientation: Int) {
switch orientation {
case 1: self = .up
Expand Down
4 changes: 2 additions & 2 deletions Tests/ImageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import PMHTTP
}()

func testGETImage() {
guard let imageData = UIImageJPEGRepresentation(sampleImage, 0.9) else {
guard let imageData = sampleImage.jpegData(compressionQuality: 0.9) else {
return XCTFail("Could not get JPEG data for sample image")
}
expectationForHTTPRequest(httpServer, path: "image") { (request, completion) in
Expand Down Expand Up @@ -92,7 +92,7 @@ import PMHTTP
}

func testPOSTImage() {
guard let imageData = UIImageJPEGRepresentation(sampleImage, 0.9) else {
guard let imageData = sampleImage.jpegData(compressionQuality: 0.9) else {
return XCTFail("Could not get JPEG data for sample image")
}
expectationForHTTPRequest(httpServer, path: "image") { (request, completion) in
Expand Down