Replies: 2 comments 1 reply
-
Adding Unfortunately you will also have to do the same for every object extension Textract.DetectDocumentTextResponse: Encodable {
func encode(to encoder: Encoder) {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.blocks, forKey: .blocks)
try container.encode(self.detectDocumentTextModelVersion, forKey: .detectDocumentTextModelVersion)
try container.encode(documentMetadata, forKey: .documentMetadata)
}
private enum CodingKeys: String, CodingKey {
case blocks = "Blocks"
case detectDocumentTextModelVersion = "DetectDocumentTextModelVersion"
case documentMetadata = "DocumentMetadata"
}
} |
Beta Was this translation helpful? Give feedback.
-
You could add a middleware that saves the responses. eg class CacheResponsesMiddleware: AWSServiceMiddleware {
public func chain(response: AWSResponse, context: AWSMiddlewareContext) throws -> AWSResponse {
guard case .json(let byteBuffer) = response.body else { return response }
cacheByteBuffer(byteBuffer)
return response
}
} You can then create a service using that middleware let texExtract = TexExtract(client: ...).with(middlewares: [CacheResponsesMiddleware()]) |
Beta Was this translation helpful? Give feedback.
-
Hello -
I'm working with Textract and would like to save the raw json results to a file in order to avoid re-hitting the API if I've already called for a specific file.
Textract.DetectDocumentTextResponse
isDecodable
but notEncodable
. I'm trying to find the base way to save responses -- does anyone have any experience doing this? Would it be worth making a PR to make the responseEncodable
?Beta Was this translation helpful? Give feedback.
All reactions