diff --git a/API/Makefile b/API/Makefile deleted file mode 100644 index ce8acab..0000000 --- a/API/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -all: build - -build: - ./generate_wrappers.rb - -rebuild: clean build - -clean: - rm -f out/Types/* - rm -f out/Methods/* - -.PHONY: all build rebuild clean diff --git a/Sources/Telegrammer/Bot/Telegram/Bot.swift b/Sources/Telegrammer/Bot/Telegram/Bot.swift index 62697d9..3e91022 100644 --- a/Sources/Telegrammer/Bot/Telegram/Bot.swift +++ b/Sources/Telegrammer/Bot/Telegram/Bot.swift @@ -104,7 +104,7 @@ public final class Bot: BotProtocol { } if let object = object as? MultipartEncodable { - return .string(try object.encodeBody(boundary: boundary)) + return .byteBuffer(try object.encodeBody(boundary: boundary)) } return nil diff --git a/Sources/Telegrammer/Types/TelegramEncodables.swift b/Sources/Telegrammer/Types/TelegramEncodables.swift index abd8336..650a8c9 100644 --- a/Sources/Telegrammer/Types/TelegramEncodables.swift +++ b/Sources/Telegrammer/Types/TelegramEncodables.swift @@ -7,6 +7,7 @@ import Foundation import MultipartKit +import struct NIO.ByteBufferAllocator /// Represent Telegram type, which will be encoded as Json on sending to server protocol JSONEncodable: Encodable {} @@ -21,7 +22,10 @@ extension JSONEncodable { protocol MultipartEncodable: Encodable {} extension MultipartEncodable { - func encodeBody(boundary: String) throws -> String { - return try FormDataEncoder().encode(self, boundary: boundary) + func encodeBody(boundary: String) throws -> ByteBuffer { + let encoder = FormDataEncoder() + var buffer = ByteBufferAllocator().buffer(capacity: 0) + try encoder.encode(self, boundary: boundary, into: &buffer) + return buffer } }