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()
05-23-2021 23:34
05-23-2021 23:34
Are you possibly trying to run device API code in the companion?
05-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.
05-25-2021 05:42
05-25-2021 05:42
In your example, it's file.name
https://dev.fitbit.com/build/reference/companion-api/file-transfer/#readonly-name