Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to send binary data in formdata it is in console.log but not in payload #105

Open
Ujhal opened this issue Jul 24, 2024 · 1 comment

Comments

@Ujhal
Copy link

Ujhal commented Jul 24, 2024

const servicedetails = this.certificationForm.value.serviceCertifications.map((service: any, index: number) => {
const base64String = this.serviceImagePreviews[index]?.image;
let binaryData: ArrayBuffer | null = null;

if (base64String) {
console.log('yes basestring')
const base64Data = base64String.split(',')[1];
binaryData = this.base64ToBinary(base64Data);
console.log(binaryData,'binary')
}

return {
award_image: binaryData,
received_date: service.date,
remarks: service.remarks,
};
}) || [];

console.log(servicedetails, 'Service Details');
const formdata={servicedetails:servicedetails,}
console.log(formdata)
##i can see my image as binary in console log but null in payload

base64ToBinary(base64Data: string): ArrayBuffer {
const binaryString = atob(base64Data);
const len = binaryString.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
return bytes.buffer;
}

@jerbob92
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants