Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
givip committed Dec 29, 2019
2 parents 0ece615 + 6037ce1 commit 988b13e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
12 changes: 0 additions & 12 deletions API/Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/Telegrammer/Bot/Telegram/Bot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions Sources/Telegrammer/Types/TelegramEncodables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -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
}
}

0 comments on commit 988b13e

Please sign in to comment.