Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

"ReferenceError: filename not defined" in enqueuefile, but the file is send to companion

I have an issue with the file transfer API.

When I try to send a file from my smartwatch (Sense) to the companion app, it throws "ReferenceError: filename not defined", but the files do get successfully sent to the companion. Also, when I list all files in the /private/data directory, all the files that need to be sent are there. See my code below.

 

```

function sendFile(fileName) {

if (!fileName) {
console.log(`filename not specified, aborting`)
}

let dirIter
const listDir = listDirSync("/private/data");
while((dirIter = listDir.next()) && !dirIter.done) {
console.log(`file in directory ${dirIter.value}`);
}

//TODO: throws error saying that filename does not exist.
//The file did, however, get to the companion app.
outbox
.enqueueFile(`/private/data/${fileName}`)
.then(ft => {
if (filename.replace(/[0-9]/g, '')=="acc"){
statusEl.text = `Sending file ${fileName} of ${state.fileNumberRecordingAcc} ...`
display.poke()
console.log(`Sending file ${fileName} of ${state.fileNumberRecordingAcc}: queued`);
} else {
statusEl.text = `Sending file ${fileName} of ${state.fileNumberRecordingHR} ...`
display.poke()
console.log(`Sending file ${fileName} of ${state.fileNumberRecordingHR}: queued`);
}
})
.catch(err => {
console.error(`Failed to queue transfer of ${fileName}: ${err}`);
errorEl.text = "Can't send " + fileName + " to companion"
display.poke()
})
}

```

 

Does anyone have an idea what could cause this weird behaviour?

Best Answer
0 Votes
2 REPLIES 2

I see this fairly often. I suspect it's an internal error within the API. I've never known it to adversely affect anything.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Good to hear that I'm not the only one. I'm not sure if it actually affects the efficiency of the program itself, but it feels wrong to keep it in haha. But I guess that I'll have to live with it then.

Best Answer
0 Votes