Assets are a special kind of records. First of all, they can be both files or JSON documents. Furthermore they are accessible by anyone, even without authentication. They are useful to create publicly accessible elements such as, for example, images. Create an Asset: POST /admin/asset Headers See the [[General Remarks|General Remarks]] and:
Description: This API creates a new asset. The user must belong to the admin role. #### Body payload #### The body can contain the following fields:
NOTE: the server automatically detects if you are posting a file or not by the content-type header. So pay attention and set up the correct value. Returns:
Examples Object Asset:
curl -d "name=objectAsset&meta={\"name\": \"Pizza\", \"price\": 5, \"ingredients\": [\"Mozzarella\", \"pomodoro\", \"basilico\"]}" --user admin:admin -H X-BAASBOX-APPCODE:1234567890 http://localhost:9000/admin/asset
File Asset:
curl --form file=@pizza.jpg --form name=fileAsset --form meta="{\"name\": \"Margherita\", \"price\": 5, \"ingredients\": [\"Mozzarella\", \"pomodoro\", \"basilico\"]}" --user admin:admin -H X-BAASBOX-APPCODE:1234567890 http://localhost:9000/admin/asset
Note: in this case the file pizza.jpg is a file that must be into the same directory in which you run the command
Retrieve all the assets: GET /admin/asset Headers: See the [[General Remarks|General Remarks]]. The user must be an administrator Description: This API returns a JSON describing all the available assets Returns:
Delete an asset: DELETE /admin/asset/:name Headers: See the [[General Remarks|General Remarks]]. The user must be an administrator Description: This API deletes a given asset. Parameters
Returns: