Creating a ZIP binary for Asset OTA using the Cloud API?

Hey, is it possible to create the zip binary required for Asset OTA using the Cloud API?

I tried Cloud API compiling the Asset OTA example, but it just gives a .bin seemingly without any assets. I thought I would be sneaky and make my own zip by structuring it the same way the CLI does with the bin & assets folder full of assets.. that didn't work though; I get a "no application found in bundle" error on that experiment in POSTman.

I also tried the "flash a device with source code" API call (selected the main file, project.properties, and the assets), and that didn't work either.

Any thoughts?

You need to pass the whole directory structure, not the individual files, when generating an asset bundle using the cloud API. This applies to both the compile API and the flash device API.

In other words, the pathnames passed in the headers of the multipart body must have the source files in the src directory, the assets in the assets directory as specified in the project.properties, etc.

[Edit: this answer was incorrect, see below]

Hey Rick, thanks for the reply. Do you have an example? I was initially trying to do this from the provided POSTman collection. Ideally I want to do implement this on my HTML form which I send to MAKE, but currently not even my test curls are working when I try to match the Cloud API docs (two examples below with some device / key redacting).. also I should note that even though the docs say the build_target_version isn't required and it defaults to the latest, it actually gives me a long error if I don't specify it as 5.5.0 .

The flash a device with source code API example for instance. This is what I did once I was in the FileAssetExample directory:

curl -X PUT "https://api.particle.io/v1/devices/XXXXXXXXX?access_token=YYYYYYY" \
       -F build_target_version=5.5.0 \
       -F "file=@project.properties;filename=project.properties" \
       -F "file1=@src/FileAssetExample.cpp;filename=src/FileAssetExample.cpp" \
       -F "file2=@assets/logo.png;filename=assets/logo.png"

It results in this message back:

{"ok":true,"message":"Update started"}

And the code starts running, but it doesn't appear to have sent any assets over in the process.

I get a similar result when I try to use curl to compile source code:

curl -X POST "https://api.particle.io/v1/binaries?access_token=XXXXXXXXXXX" \
       -F platform_id=32 \
       -F build_target_version=5.5.0 \
       -F "file=@project.properties;filename=project.properties" \
       -F "file1=@src/FileAssetExample.cpp;filename=src/FileAssetExample.cpp" \
       -F "file2=@assets/logo.png;filename=assets/logo.png"

Result:

{"ok":true,"binary_id":"XXXXXXX","binary_url":"/v1/binaries/XXXXXXX","build_target_version":"5.5.0","expires_at":"2023-09-23T17:53:12.128Z","sizeInfo":" text\t data\t bss\t dec\t hex\tfilename\n 17518\t 124\t 3254\t 20896\t 51a0\t/workspace/target/workspace.elf\n"}

When I download it to check it out, it's always just a 20kb .bin file.

This is my unmodified project.properties:

name=FileAssetExample
assetOtaDir=assets

Can you spot what I'm doing incorrectly? :thinking:

Sorry, I wasn't thinking the first time I replied. When you create a bundle with the Particle CLI, or with Workbench, which uses the Particle CLI, the bundle is built locally.

In other words, if you cloud compile, it uses the compile API to build the .bin file, then locally combines it with the assets to create a zip. There's no cloud function to create a bundle zip in the cloud.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.