Hi guys
I have a java rest service answering with a base64 file content (for example a pdf or an image). But the first question is: which is the best way to display the file content?
Unsure on what to do, I decided to put a webkit view in my page and to execute the following code:
if let decodeData: Data = Data(base64Encoded: download.fileContent!, options: NSData.Base64DecodingOptions.ignoreUnknownCharacters) {
DispatchQueue.main.sync() {
self.webView.load(decodeData, mimeType: "application/pdf", characterEncodingName: "utf-8", baseURL: URL(fileURLWithPath: ""))
}
}But the file isn't displayed in the webview and the console logs the error: "failed to find PDF header: `%PDF' not found"
I don't know how to solve the problem. I'm using swift4 and xcode9.
Thanks in advance