Media Vault settings define which media files extensions are allowed for direct upload to Media Vault, and Image preprocessing provider settings let you define which options to use when creating derived images. Fun fact: File extensions that aren’t allowed for direct upload to Media Vault will still be stored in the Vault when uploaded through other modules.

Media Vault settings

To check current Media Vault settings, use the GET method on the Media Vault settings endpoint.

curl
-X GET
-H "Authorization: bearer <access token>"
"http://api.baasic.com/<version>/<api-key>/media-vault-settings/"

As a result, you should get a list of all allowed file extensions like this:

{
    "uploadAllowedExtensions": ".rtf,.doc,.docx,.pdf,.txt,.xml,.xls,.xlsx,.ppt,.pptx,.zip,.rar,.7z,.bmp,.gif,.jpg,.jpeg,.tif,.tiff,.png,.svg,.avi,.flv,.swf,.wmv,.mpeg,.mpg,.mp4,.mp3,.mov,.m4a,.3gp,.rm,.ogv,.webm,.mpe",
    "dateCreated": "2016-05-24T13:58:52.404236",
    "dateUpdated": "2016-05-24T13:58:52.404236",
    "id": "NCrJzoAiIwRQ35C8099FzC"
}

To update Media Vault settings, simply PUT new settings using a request similar to this:

curl
-X PUT
-H "Content-Type: application/json"
-H "Authorization: bearer <access-token>"
-d '{
"uploadAllowedExtensions": ".jpg,.png,.doc"
}'
"http://api.baasic.com/<version>/<api-key>/media-vault-settings/"

Note that this replaces all previously allowed file extensions with new ones, and as a response you should just get the code 204 (the server successfully processed the request, but is not returning any content).


Preprocessing settings

Preprocessing settings are used to set options for each preprocessing provider. For now, there’s only one - Image preprocessing provider, with options on how derived images should be created, such as crop and face detection. In the future, when more preprocessing providers are available, each of them will have its own JSON object with options and settings.

To list all preprocessing settings, a GET request is sent to the endpoint like this:

curl
-X GET
-H "Accept: application/json"
-H "Authorization: bearer <access token>"
"http://api.baasic.com/<version>/<api-key>/media-vault-preprocessing-settings/"

The resulting JSON response will show all available preprocessing provider options: three crop modes (fill, fit, scale), and two options for face detection (true or false). Settings part will show you which options are currently selected.

{
    "embed": null,
    "item": [
        {
            "abrv": "image-preprocessor",
            "name": "Image Preprocessing Provider",
            "dateCreated": "2016-05-24T14:41:27.888551",
            "dateUpdated": "2016-05-24T14:41:27.888551",
            "id": "QO3IYy3rb2DPG5C809ZFk0",
            "options": {
                "cropMode": [
                    "fill",
                    "fit",
                    "scale"
                ],
                "faceDetection": [
                    true,
                    false
                ]
            },
            "settings": {
                "cropMode": "fit",
                "faceDetection": false
            }
        }
    ],
    "links": [],
    "page": 1,
    "recordsPerPage": 5,
    "searchQuery": null,
    "sort": null,
    "totalRecords": 1
}

In our introductory post about Media Vault, we talked about derived images. The option to create modified versions of one original image on the fly is super useful, and now we’ll see how to create them using Media Vault preprocessing settings endpoint.

To create a derived version of your resource, just use the GET method with the desired parameters - the server will seamlessly create the requested version and return it in the response (code 200 OK).

curl
-X GET
-H "Accept: application/json"
-H "Authorization: bearer <access-token>"
"http://api.baasic.com/<version>/<api-key>/media-vault-streams/<file-id>/?width=150&height=150"

To update preprocessing settings, we’ll be using PUT method request to that endpoint:

curl
-X PUT
-H "Content-Type: application/json"
-H "Authorization: bearer <access-token>"
-d '{
    "abrv": "image-preprocessor",
    "name": "Image Preprocessor",
    "options": {
        "cropMode": ["fit", "fill", "scale"],
        "faceDetection": [true, false]
    },
    "settings": {
        "cropMode": "fill",
        "faceDetection": false
    }
}'
"http://api.baasic.com/<version>/<api-key>/media-vault-preprocessing-settings/image-preprocessor"

This will update settings with new ones, and as a response, you should just get the code 204 (the server successfully processed the request, but is not returning any content).

As we said, there’s only one preprocessing provider (image preprocessing provider) available for now, but once Baasic gets more of them, you’ll find the search option very useful. To see parameters used for the search request, click here.

Image preprocessing provider settings defined in the Media Vault are valid for all other modules that support upload and image processing.

Feel free to leave a comment

comments powered by Disqus