imports/vx/server/code/vxapp.js
/**
     * Convert a given image at the end of a URL to data URL format.
     *
     * @param {string} url Web URL pointing to image.
     * @return {string} Data URL.
     */
Convert a given image at the end of a URL to data URL format.
@param {string} url Web URL pointing to image.
@return {string} Data URL.
Convert a given image at the end of a URL to data URL format . @param { string } url Web URL pointing to image . @return { string } Data URL .
async toDataUrl(url) {
        try {
            if (!_.isString(url)) {
                OLog.error(`vxapp.js toDataUrl parameter check failed url=${url}`)
                return { success: false, icon: "EYE", key: "common.alert_parameter_check_failed" }
            }
            if (!Meteor.userId()) {
                OLog.error("vxapp.js toDataUrl security check failed user is not logged in")
                return { success: false, icon: "EYE", key: "common.alert_security_check_failed" }
            }
            const response = await fetch(url)
            const arrayBuffer = await response.arrayBuffer()
            const dataUrl = `data:image/jpeg;base64,${VXApp.arrayBufferToBase64(arrayBuffer)}`
            return { success: true, icon: "CHECK", key: "common.alert_transaction_success", dataUrl: dataUrl }
        }
        catch (error) {
            OLog.error(`vxapp.js toDataUrl unexpected error=${error}`)
            return { success: false, icon: "BUG", key: "common.alert_unexpected_error",
                variables: { error: error.toString() } }
        }
    }
async toDataUrl ( url ) { try { if ( ! _ . isString ( url ) ) { OLog . error ( ` ${ url } ` ) return { success : false , icon : "EYE" , key : "common.alert_parameter_check_failed" } } if ( ! Meteor . userId ( ) ) { OLog . error ( "vxapp.js toDataUrl security check failed user is not logged in" ) return { success : false , icon : "EYE" , key : "common.alert_security_check_failed" } } const response = await fetch ( url ) const arrayBuffer = await response . arrayBuffer ( ) const dataUrl = ` ${ VXApp . arrayBufferToBase64 ( arrayBuffer ) } ` return { success : true , icon : "CHECK" , key : "common.alert_transaction_success" , dataUrl : dataUrl } } catch ( error ) { OLog . error ( ` ${ error } ` ) return { success : false , icon : "BUG" , key : "common.alert_unexpected_error" , variables : { error : error . toString ( ) } } } }
Convert a given image at the end of a URL to data URL format.
Convert a given image at the end of a URL to data URL format .