Get deployment size


According to the docs, the GET /api/devices/v1/deployments/device/deployments/next request returns the following JSON structure on success:

  "id" : "w81s4fae-7dec-11d0-a765-00a0c91e6bf6",
  "artifact" : {
    "artifact_name" : "my-app-0.1",
    "source" : {
      "uri" : "",
      "expire" : "2016-03-11T13:03:17.063+0000"
    "device_types_compatible" : [ "rspi", "rspi2", "rspi0" ]

Is there a way to also get the size of the deployment image? I suppose I can just use curl to get this information from the header, but I was just hoping there was a standard way to get it from Mender that I’m just not seeing.

To add to this, I found a way to get the image size via curl, but not in a straight forward way. The following command is supposed to only get the header information from the URL without actually downloading the file but I always get back a “403 forbidden” error.

curl -sI $URL

If this worked I would be able to inspect the Content-Length and be done but it seems that the hosted Mender option doesn’t respond to header requests. Is this true or am I just doing this wrong? My workaround was to start a regular curl download but abort immediately after starting. This still retrieved the header and I was able to get the Content-Length without issue.


thanks for giving Mender a try!
I would try it in the following way (replace with or your hostname):

# login
jwt=`curl -k -X POST -H "Content-Type: application/json;" -u 'xxxx:xxxx'`;

# get given deployment, in this example its id is: 9be037f4-e16d-46ef-885c-e51a5cc59664
curl -vvv -k -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $jwt" '' | jq .;
  "name": "All devices",
  "artifact_name": "reboot-script-v1.0",
  "created": "2020-07-18T06:30:59.733Z",
  "finished": "2020-07-18T06:38:22.006Z",
  "id": "9be037f4-e16d-46ef-885c-e51a5cc59664",
  "artifacts": [
  "status": "finished",
  "device_count": 1,
  "retries": 2,
  "max_devices": 1

# take note that the artifact was: c839ea50-a762-4552-a2ff-0d2ef836c7e0
# get the arifact size
curl -vvv -k -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $jwt" '' | jq .size

is that what you were after?

best regards,

Ah yes, thanks! I wasn’t looking at the management API so I missed this.

A question though: in what cases would you get multiple artifact IDs for a given deployment? Maybe if you were using update modules? I think in my case there should only be one so I would assume to use the zero element of the “artifacts” array.

I believe you can get multiple artifacts if you have artifacts for multiple device types under the same Release name. For example two artifacts named reboot-script-v1.0 for the device types raspberrypi3 and raspberrypi4, respectively.

1 Like