ManageIQ/manageiq-ui-classic

View on GitHub
app/javascript/helpers/toBase64.js

Summary

Maintainability
A
0 mins
Test Coverage
//encodes recieved file to Base64
const toBase64 = (file) =>
  new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = () => resolve(reader.result);
    reader.onerror = (error) => reject(error);
  });

export default toBase64;