I am trying to retrieve VersionData with a standard REST API call from a VisualForce Page a then upload it to a S3 bucket but end up with corrupted files. I believe this is an encoding problem on the client side as plain text or CSVs work like a charm. I can upload VersionData from Apex but there are heap and request size limitations so I need to send the data from the client.
Any ideas how to properly process images or pdf files? Thanks a lot
THE PROBLEM IS NOW SOLVED
Files should not be treated as strings. I solved the problem by leaving jQuery's ajax as I did not succeed to request a response type. By switching to plain JS and making a GET call (XMLHttpRequest) with response type set to blob I received an Object, instead of a string. Base64 string can be then retreived using JS FileReader.