05-23-2021 22:57
05-23-2021 22:57
In this code below, is there any function to call the filename?
When I use "inbox.nextFile();" I get error msg that "e.inbox.nextFile is not a function"
import { inbox } from "file-transfer";
// Process the inbox queue for files, and read their contents as text
async function processAllFiles() {
let file;
while ((file = await inbox.pop())) {
const payload = await file.text();
console.log(`file contents: ${payload}`);
}
}
// Process new files as they are received
inbox.addEventListener("newfile", processAllFiles);
// Also process any files that arrived when the companion wasn’t running
processAllFiles()
Best Answer05-23-2021 23:34
Gold Fitbit Product Experts share support knowledge on the forums and advocate for the betterment of Fitbit products and services. Learn more
05-23-2021 23:34
Are you possibly trying to run device API code in the companion?
Best Answer05-24-2021 09:47 - edited 05-24-2021 10:00
05-24-2021 09:47 - edited 05-24-2021 10:00
No, I am not.
I am trying to transfer a file from device to companion which has its local storage and I need to get the name of file.
I know how to store it in local storage but don't know how to get the name.
Best Answer05-25-2021 05:42
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
05-25-2021 05:42
In your example, it's file.name
https://dev.fitbit.com/build/reference/companion-api/file-transfer/#readonly-name
Best Answer