Broken Buffer Serialization?

I am developing a http-functions.js function that is supposed to fetch a binary file, then push it to the browser. This needs to be server side for some future security. It appears as though the response stream is corrupt.

import {fetch} from ‘wix-fetch’;

export async function get_sample(request) {
if (request.path[0] === “findMe”) {
const url = “https://www.utoledo.edu/library/help/guides/docs/apastyle.pdf”;
var contentType;

const results = await fetch(url, {method: ‘get’})
.then( function (result) {
contentType = result.headers.get(‘content-type’);
return result.buffer();});
let response = ok({headers: {
“Content-Type”: “application/pdf”,
“Content-Disposition”:“attachment;filename=‘downloaded.pdf’”
},
body:results.toString(‘binary’)});
return response;
}

const body = “Can’t find it!”;
return notFound({body: body});
}

The above code does not properly send the file. The file is corrupt. When I am running this code via a Wix jws function, I can see that the Buffer data appears to have been modified (UTF8 conversion?).

Can anyone see any glaring issues in this code?

Hello Patrick were you able to find the answer to this?

Hello. How can I convert the selected file into Buffer, Stream, or Blob? Any idea?

look at -
https://www.wix.com/velo/forum/community-discussion/how-to-get-a-file-content-in-wix/p-1/dl-605cc2142ed269002c684dd6?commentId=605cc2142ed269002c684dd6&origin=notification&postId=605cba8fca1dc3002bff8448

I’ve posted a code example there