Skip to content

Instantly share code, notes, and snippets.

@shanwixcode
Created May 27, 2021 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanwixcode/a96e5d46d33b8e57539ed0ebc10ec739 to your computer and use it in GitHub Desktop.
Save shanwixcode/a96e5d46d33b8e57539ed0ebc10ec739 to your computer and use it in GitHub Desktop.
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