MCPcopy Create free account
hub / github.com/microsoft/SandDance / upload

Method upload

docs/app/js/sanddance-app.js:51780–51808  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

51778 });
51779 }
51780 upload(e) {
51781 if (e.target.files) {
51782 const file = e.target.files[0];
51783 const split = file.name.split(".");
51784 const type = split[split.length - 1];
51785 if (DataSourcePicker.urlTypes.indexOf(type) >= 0) {
51786 const reader = new FileReader();
51787 reader.onload = ()=>{
51788 const id = file.name;
51789 const displayName = file.name;
51790 const rawText = reader.result;
51791 const ds = {
51792 dataSourceType: "local",
51793 displayName,
51794 id,
51795 rawText,
51796 type
51797 };
51798 this.changeDataSource(ds);
51799 };
51800 reader.readAsText(file);
51801 } else {
51802 const uploadFormatError = (0, _language.strings).errorInvalidFileFormat;
51803 this.setState({
51804 uploadFormatError
51805 });
51806 }
51807 }
51808 }
51809 loadUrl() {
51810 if (!this.state.url) return this.setState({
51811 urlError: (0, _language.strings).errorNoUrl

Callers 1

renderMethod · 0.95

Calls 1

changeDataSourceMethod · 0.95

Tested by

no test coverage detected