Created
May 27, 2021 13:10
-
-
Save shanwixcode/a96e5d46d33b8e57539ed0ebc10ec739 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {getFileUrl, sendMail} from 'backend/attachment/process'; | |
$w.onReady(function () { | |
}); | |
export function upload_click(event) { | |
$w("#upload").disable(); | |
let files = $w("#uploadButton1").value; | |
let fileName = files[0].name; | |
let fileType = /[^.]*$/.exec(fileName)[0]; | |
$w("#uploadButton1").startUpload() | |
.then( (res) => { | |
let mediaId = res.mediaId; | |
getFileUrl(mediaId) | |
.then( (url) => { | |
let email = $w("#email").value; | |
let subject = $w("#subject").value; | |
let body = $w("#body").value; | |
let attachName = $w("#attName").value; | |
sendMail(url, email, subject, body, attachName, fileType) | |
.then( (res) => { | |
console.log(res); | |
$w("#upload").enable(); | |
}); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment