To add a file to a media library, take the following steps:
- Upload the file to Control Panel.
- Add the file to the media library of a specific catalog.
File uploading to the Control Panel
To upload file to the Control Panel, use the following request:
1
| POST /catalogs/upload_files
|
1
| curl -i -X POST -u user:userpass -H "Content-Type: multipart/form-data" http://onapp.test/catalogs/upload_files -F "file=@/home/username/test_disk.iso" -F "vcloud_media[folder]=my_folder"
|
Where:
vcloud_media[folder] - path, where the media file is stored
To add a file to the media library, use the following request:
1
2
| POST /catalogs/:id/media.xml
POST /catalogs/:id/media.json
|
XML Request Example
1
| curl -i -X POST -u user:userpass -H 'Accept: application/xml' -H 'Content-Type: application/xml' http://onapp.test/catalogs/12/media.xml -d '<vcloud_media><label>Media</label><folder>path</folder></vcloud_media>'
|
JSON Request Example
1
| curl -i -X POST -u user:userpass -H 'Accept: application/json' -H 'Content-Type: application/json' http://onapp.test/catalogs/12/media.json -d '{"vcloud_media":{"label":"Media","folder":"path"}}'
|
Where:
label* - the name of the media file
folder* - path where the media file is situated (the same folder, as indicated during file uploading to the Control Panel)