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.
POST /admin/asset
Headers See the 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
GET /admin/asset
Headers: See the 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. The user must be an administrator
Description: This API deletes a given asset.
Parameters
Returns:
Remark: These APIs work only if the parameter asset is an image
Resize the image with a fixed width and height:GET /asset/:name/resize/:w/:h
Headers: See the General Remarks. The user must be an administrator
Description: Resize image with a specified width and height
Parameters:
Returns:
Resize the image with a fixed percentual:GET /asset/:name/resize/:perc
Headers: See the General Remarks. The user must be an administrator
Description: Resize image with a specified percentual
Parameters:
Returns:
Apply a resizeId:GET /asset/:name/resizeId/:sizeId
Headers: See the General Remarks. The user must be an administrator
Description: applies a resizing which is specified in the settings for the admin dashboard, according to the index that was set as a parameter. For example: if the settings are [10%,25%,50%,75%] and you use the following API GET /asset/test/resizeId/1, the name test image will be scaled by 10%
Parameters:
Returns: