You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Report File content should not always be treated as text. In some cases it can be a binary format (e.g. PDF) which cannot be encoded as a text in .NET (be it ASCII, UTF8...) and must be treated as a byte array / stream / base64 so that it can be properly stored.
Expected behavior
Report File content accurately contains the original file bytes.
Current behavior
Report File content contains a string encoding of the original file bytes, which when encoded back into binary form will be missing data.
Steps to reproduce
Download the PDF file via command line (e.g. PowerShell) Invoke-RestMethod -Method Get -Uri 'https://api.checkout.com/reports/REPORT_ID/files/FILE_ID' -Headers @{"Authorization"="SECRET"} -OutFile original.pdf
Download the same PDF file using the Checkout SDK and attempt to save in any of the available text encodings
usingCheckout;usingSystem.Text;ICheckoutApiapi=CheckoutSdk.Builder().StaticKeys().SecretKey("SECRET").Environment(Checkout.Environment.Production).Build();varreportId="REPORT ID WHERE .Files[0].Format == PDF";varreport=awaitapi.ReportsClient().GetReportDetails(reportId);varfile=awaitapi.ReportsClient().GetReportFile(reportId,report.Files[0].Id);File.WriteAllBytes("report.pdf",Encoding.Unicode.GetBytes(file.Body));File.WriteAllBytes("report2.pdf",Encoding.UTF8.GetBytes(file.Body));File.WriteAllBytes("report3.pdf",Encoding.ASCII.GetBytes(file.Body));File.WriteAllBytes("report4.pdf",Encoding.UTF32.GetBytes(file.Body));File.WriteAllBytes("report5.pdf",Encoding.Latin1.GetBytes(file.Body));File.WriteAllText("report6.pdf",file.Body,Encoding.ASCII);
Observe that none of the PDF files that had their bytes text encoded previously is keeping the original file bytes:
Possible solution
I may be able to implement this bug fix
Additional information
The text was updated successfully, but these errors were encountered:
@miguel-ferreira-cko We raised this issue time ago, the thing is that this endpoint is a redirect, and previously this endpoint was always returning a string, in worst case we should return only the string of the redirect and merchant should handle the type of the content based on the response.
@armando-ibarra-cko this endpoint has always returned 302 Redirect into a pre-signed location within AWS S3 that downloads a file. The HttpClient in .NET follows redirect links by default.
The response type of GetReportFile on the SDK could simply be the HttpClient Response itself
Environment
Description
Report File content should not always be treated as text. In some cases it can be a binary format (e.g. PDF) which cannot be encoded as a text in .NET (be it ASCII, UTF8...) and must be treated as a byte array / stream / base64 so that it can be properly stored.
Expected behavior
Report File content accurately contains the original file bytes.
Current behavior
Report File content contains a string encoding of the original file bytes, which when encoded back into binary form will be missing data.
Steps to reproduce
Invoke-RestMethod -Method Get -Uri 'https://api.checkout.com/reports/REPORT_ID/files/FILE_ID' -Headers @{"Authorization"="SECRET"} -OutFile original.pdf
Possible solution
Additional information
The text was updated successfully, but these errors were encountered: