I am trying to send a text file to a companion(simulator) from device(simulator).
With the sample code in "https://dev.fitbit.com/build/guides/communications/file-transfer/", the companion only reads the contents of file via console.log.
When I try to import "fs" in compaion, I got error that "cannot resolve fs".
Is there an example code to save the file in folder related to the companion?
Answered! Go to the Best Answer.
Best Answerfs is device-only.
The companion uses file-transfer.
This isn't sufficient to save the file into an accessible folder. For that, you'll need to use fetch() with a web server.
Best Answerfs is device-only.
The companion uses file-transfer.
This isn't sufficient to save the file into an accessible folder. For that, you'll need to use fetch() with a web server.
Best AnswerDoes the companion store the files received from the devices locally? Or it uploads it to the cloud automatically. And the developer needs to query them using the Web API?
Related to this topic .. I have a file that I get using fetch from aws. I am trying to send that data to my device but I get
[4:31:12 PM] Companion: Failed to queue session_config.json: TypeError: Failed to execute 'enqueue' on 'FileTransferOutbox': The value provided as parameter 2 is not a valid buffer source (companion/index.js:82,7)my code is this:
console.log('Enqueue file to device');
outbox.enqueue(config_fname, config_data)
.then((ft) => {
console.log(`Transfer of ${ft.name} successfully queued.`);
})
.catch((error) => {
console.log(`Failed to queue ${config_fname}: ${error}`);
})where config_data is what I get from my fetch. What am I missing?
Best Answerso I ran fetch on companion app and I was wondering if I can run the same thing on the watch directy.
going back to the transfer, I was able to transfer the file but when I try to read it using
fs.readFileSync(configFilename)I get
App: Unhandled exception: Error: Couldn't find file: undefined
Best AnswerNo, the fetch API only exists in the companion. The watch doesn't have direct access to networking.
Where did you get configFilename from? When are you trying to read the file?
Best Answer
Best Answer
Best Answer