I’m trying to download a PDF, but when I open it everything is blank.
If I open it with notepad and compare it with the original PDF, that’s almost right. I think the error is because of the encoding.
The problem is probably with httpGet, not system.perspective.download - once you’re downloading the file, there’s no encoding.
Since you’re already in 8.0, I would highly recommend migrating to system.net.httpClient.
Unlike httpGet, it will try to use the charset from the Content-Type header in the response - and if one is not found, it falls back to UTF-8, instead of the platform’s default charset (which is UTF-8 on basically every platform except Windows), as system.net.httpGet() does.
It would be a drop in replacement for the existing code you have:
@PGriffith, I am facing a very similar problem right now, but when I upload a file, could you help me?
I’m using the ‘File upload’ component in perspective, trying to upload a file to Google Drive.
The file arrives in the Google Drive folder, but with the wrong encoding.
Why are you not using .getBytes() if you are just saving the file to the filesystem? Converting from bytes to string back to bytes is not guaranteed to be idempotent.
You should be constructing your upload with binary (probably base64) encoding of the bytes, not a string. PDFs have binary content and will not decode/reencode properly as strings.