The Media service in Yaas could be used to store your media files. Here we will try it step by step.
1. Subscribe the Media service in your dev team.
2. Create a new service in your dev team with the scope “hybris.media_view” and “hybris.media_manage”.
3. Get the “Client ID” and “Client Secret” of your service. And the “Identifier” of your dev team as the tenant.
4. Execute the following command in your cmd window to get the token. PAY ATTENTION that the red part should be changed to your own id and secret.
curl -i -H “Content-Type: application/x-www-form-urlencoded” -X POST -d “grant_type=client_credentials&scope=hybris.media_manage hybris.media_view&client_id=xxxxxx&client_secret=xxxxx” http://api.yaas.io/hybris/oauth2/v1/token
5. To upload a file to media repository, firstly we need to send a post request to https://api.yaas.io/hybris/media/v2/files to get the upload link and commit link. PAY ATTENTION that for the Authorization part, the token should be started with “Bearer”. The body indicates that the type of the file that you want to upload.
Then you will get the upload link and the commit link as response. The upload link is used to upload the file. After that the file is temporally stored in media repository. You need to send a request to the commit link to make the uploading finalized.
6. Send a put request to the upload link to upload the file.
7. Send a post request to the commit link to commit the file. Then you will get the id and link of the media file.
8. You can get the real download link of the file by sending a get request to the link.
9. To see the list of the files in your media repository, you can send a get request to https://api.yaas.io/hybris/media/v2/files?tenant=congdevteam, PAY ATENTION that the red part should be changed to your own tenant.