From 8a7e6f5bdd2f274685f5fdfca097e59efa8a56f9 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Wed, 1 Feb 2023 00:08:02 -0800 Subject: [PATCH] Fix code example in readme --- Readme.md | 6 +++--- Sources/Osiris/HTTP.swift | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Readme.md b/Readme.md index acc666d..022482e 100644 --- a/Readme.md +++ b/Readme.md @@ -15,9 +15,9 @@ Create an encoder and then add parts to it as needed: let avatarData = UIImage(from: somewhere).jpegData(compressionQuality: 1) let encoder = MultipartFormEncoder() let body = try encoder.encodeData(parts: [ - .text(name: "email", text: "somebody@example.com"), - .text(name: "password", text: "secret"), - .binary(name: "avatar", type: "image/jpeg", data: avatarData, filename: "avatar.jpg"), + .text("somebody@example.com", name: "email"), + .text("secret", name: "password"), + .data(Data(), name: "avatar", type: "image/jpeg", filename: "avatar.jpg"), ]) ``` diff --git a/Sources/Osiris/HTTP.swift b/Sources/Osiris/HTTP.swift index 72b2dbf..a59bd42 100644 --- a/Sources/Osiris/HTTP.swift +++ b/Sources/Osiris/HTTP.swift @@ -70,10 +70,9 @@ struct HTTPRequest { assertionFailure() return } - parts.append(MultipartFormEncoder.Part( - name: name, - content: .binaryData(data, type: "image/jpeg", filename: filename ?? "image.jpeg") - )) + parts.append( + .data(data, name: name, type: "image/jpeg", filename: filename ?? "image.jpeg") + ) } #endif }