mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-01 04:12:22 +03:00
37 lines
1 KiB
JavaScript
37 lines
1 KiB
JavaScript
/* ----------------------------------------------------------------------------
|
|
* Easy!Appointments - Online Appointment Scheduler
|
|
*
|
|
* @package EasyAppointments
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
|
* @copyright Copyright (c) Alex Tselegidis
|
|
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
* @link https://easyappointments.org
|
|
* @since v1.5.0
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
/**
|
|
* File utility.
|
|
*
|
|
* This module implements the functionality of files.
|
|
*/
|
|
window.App.Utils.File = (function () {
|
|
/**
|
|
* Convert a file to a base 64 string.
|
|
*
|
|
* @param {File} file
|
|
*
|
|
* @return {Promise}
|
|
*/
|
|
function toBase64(file) {
|
|
return new Promise((resolve, reject) => {
|
|
const reader = new FileReader();
|
|
reader.readAsDataURL(file);
|
|
reader.onload = () => resolve(reader.result);
|
|
reader.onerror = (error) => reject(error);
|
|
});
|
|
}
|
|
|
|
return {
|
|
toBase64,
|
|
};
|
|
})();
|