Hi Anders,
There is a tiny issue in your code:
let toUpdate = {
"_id": "f5ea6533-ad44-40a1-a1f6-1f5cc5d94ac5",
"applicationPdf": httpResponse,
};
What you are saving is the HttpResponse object of Fetch (that’s where all those properties come from). Not the actual PDF data.
The data needs to be read from the response first, then safely encoded to a string that can be stored in the database.
Something like
fetch('url-of-some-pdf')
.then(response => response.body.getReader().read())
.then(body => {
const base64Body = btoa(String.fromCharCode.apply(null, body.value))
wixData.save('pdfStore', { _id: '...', applicationPdf: base64Body})
})
When reading the data, applicationPdf fields can be converted back to binary using atob function.
However, note that Wix Data has a limit of 0.5MB for a single document. Long documents or documents that contain images can grow larger than this limit.
Some relevant documentation: