So have a couple questions in regards to using mender-cli and the mender API with the new file transferring feature.
Question #1 - How do i properly use mender-cli to conduct a file transfer to/from a device. Please note that I am using ‘.mender-clirc.json’
Currently for uploading to a device, i have used this full command:
I have looked at all available documentation and even tried going through the actual source code, but it doesn’t mention anywhere how to add the file mode header to the command above. To that point, I have no clue how to do the reverse command of requesting a file from remote device, to be locally downloaded, if someone would also be able to elaborate on this matter, I’d greatly appreciate it.
Question #2 - I would also like to try using the mender API (using JavaScript) for file transfers.
Do i need to login by means of a Token or something? Is using this feature of the mender API part of the Mender Open-Source model? or is it only available with a paid mender subscription?
Thanks guys, really appreciate someone taking the time to look into this, this has been driving me nuts.
and thank you for trying File Transfer. as for the first question, could you tell me what mender-cli version are you using?
To use the API you need to have a valid JWT token, so yes, you need to authorize.
The File Transfer is part of the Troubleshoot add-on package
So I’m using the latest mender-cli version (53b85e0).
For the JWT Token, are we able to acquire this token with an API Login request, while being on open-source? From my understanding this should be the functionality (and the JWT Token is different from a Two factor authentication token, is this correct?)
Little update in regards to using the API, I managed to get the JWT token but now I’m having issues figuring out the CORS policy headers that the API is looking for, for the file transfer. This is currently what I have, and also the error that I am receiving.
regarding the API usage from js, is that an on-premise setup, meaning that you are running the server? (I can only gather that you are calling API from js from different domain that the server runs, am I mistaken?)
The server that I am trying to access is an on-premise server (it will be an AWS server in the future). So it has a full server URL during the API call.
yes, it did. I guess in that case you will have to modify the api-gw CORS headers, from the top of my head I can’t give you the solution, I would start by looking into the container, and playing with the configuration.
Okay gotcha, I’ll do that as my first step in the right direction.
As for the mender-cli, I may have stumbled upon how the command needs to be called between a upload/download (by looking through the source code), it seems that these positions just need to be reversed, I have not confirmed this though (still unsure of how to provide the file mode, getting the same error “FAILURE: Missing X-MEN-FILE-MODE header”):
I think I may have misunderstood you. So the server is on a AWS cloud server. I am running my script outside of the server space, so it is local to me but remote to the server.
Does this change your input at all?
I have asked our administrator to look into the configuration setup of the server, but they are having a difficult time locating where the CORS policy would be kept. Would you happen to know the location of it on the server?
mender-cli cp ffe2ff6f-ed2d-4d24-8ff8-5c0dff65d1ff:/etc/profile /tmp/p --server https://myhostname --skip-verify
Configuration file not found. Continuing.
Successfully downloaded the file: "/etc/profile" from device ...
could you tell me what version of deviceconnect you are running with executing:
./deviceconnect --version
from the deviceconnect container?
the CORS: you should be able to do what you want, by checking /etc/traefik/config directory and using Headers - Traefik let me know if you run into problems, I can get some traefik experts online.
Not sure what i’m doing that is different. I was thinking that maybe the mender-cli might have been out of date, even though we confirmed it, so I just downloaded the latest one from here: Downloads | Mender documentation, and I’m still getting the same error of ‘FAILURE: Missing X-MEN-FILE-MODE header’. I presume the link on the downloads page is the latest one?
So the deviceconnect version is 1.0.0.
Sounds good about the CORS, will dig into that and test.
one follow up question: does the file transfer work from the UI?
could I have the docker ps output? the deviceconnect 1.0.0 is a bit ancient, and it does not add the file mode header. which version of the Mender Server are you running?
ok, I checked again on a clean setup, I cant replicate the problem with v2.7 and the file transfer, it works here. although I am trying demo, but it should be the same, since it pulls the same images. at the moment I am out of ideas, I will let you know when I have anything. When time permits I will run 2.7 production installation and check.
sorry I could not help more.
Thank you for putting in as much time as you already have into this, I really appreciate it!
So just to update what I’ve done on my end, I haven’t been able to get mender-cli working or the mender API with HTML/JavaScript/NodeJS (CORS Issues), but I was able to get it working using Python. Which makes me think that the CORS issues must be related to how I’m setting the headers or how the browser is interpreting it.
If you do happen to think of anything, please let me know! Thanks again for your help, till then!