Can't upload file using SDK

  • 4 January 2024
  • 1 reply
  • 24 views

Badge

I used the app SDK quickstart to make an app. Up until an hour ago, it was working. Then the file input stopped working. I haven’t touched this part of the code (to my knowledge) and the file select input event handler is not triggering at all.

 I have the following code:
app.js

document.getElementById('csvFileInput').addEventListener('change', handleFileSelect, false);

function handleFileSelect(event) {
console.log('file');
const file = event.target.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
const contents = e.target.result;
const rowsArr = processCSV(contents);
buildGraph(rowsArr);
};
}
}
...

app.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://miro.com/app/static/sdk/v2/miro.js"></script>
<title>My App</title>
</head>
<body>

<div id="root">
<div class="grid wrapper">
<div class="cs1 ce12">
<input type="file" id="csvFileInput" />
</div>
</div>
</div>
<script src="/src/app.js"></script>
</body>
</html>

Please help!


1 reply

Userlevel 3
Badge

Hi @Trevor Fox 

I’ve just ran the code on my machine using npx-create-miro-app and then choosing vanilla JavaScript and then adding in the code you’ve mentioned above. 

Everything works fine on my end. I was able to add in a .csv file and have it showing in the app panel. 

Are you seeing any error messages in the console? 

 

 

Reply