How to Check-In and Check-Out an Asset using MediaValet's API?

Documentation Reference: How to Create a New Asset Version

Step 1: Authenticate to the library you wish to connect to, following the steps in: MediaValet API

Step 2: Find the asset you wish to perform the versioning on (check-out/check-in) by using the following endpoint: https://docs.mediavalet.com/#3e177f88-9661-43c2-b9ed-47e5112da975:~:text=GET-,Retrieve%20Asset,-https%3A//api.mediavalet

  • Example: GET/ https://api.mediavalet.com/assets/:assetId?includeSoftDeleted=false

Step 3: Perform a checkout against the asset in question by perform a POST request against the following endpoint: https://api.mediavalet.com/assets/:assetId/checkOut
(Optional): If you wish to leave a comment for the Check-Out as is the case in the portal UI, you can pass the following as a raw JSON payload body:

[
"Test"
]
  • Note: “Test” would be replaced with whatever comment you wish to keep. This step is optional and can be skipped if you wish to leave no comment.


If successful, you will receive a response that looks similar to the below:

d4d19e17-97be-48de-90fc-75ca6db65946.png


Download the version of the asset that was checked out from the SAS URL that is returned in the response if making modifications directly to the asset currently in the DAM. In the example above, this is:

https://mvsfservicefabriccato.blob.core.windows.net/medialibrary-6689ba35b0a04ba6b9f76e0da614d19e/3b9d4cc3b5be481e8ce1d5ba00a1245b/3b9d4cc3b5be481e8ce1d5ba00a1245b/Original/moeder_en_zoon_low_res_0.jpg?sv=2017-04-17&sr=b&si=202207291805&sig=lcCjz2GKDjA4MO9RFEVlmPNQY3mywrE1BPVYVEwMd7Q%3D&st=0319-04-22T16%3A00%3A28Z&se=2034-03-19T06%3A08%3A00Z&rsct=application%2Foctet-stream&rscd=file%3B%20attachment

If you wish to check in an entirely new version of the asset without needing to make any modifications to the current version in the DAM that was checked out, skip to Step 4

 

Step 4: Check-In Asset

  • Part A: Validate Asset Check-In
    • Perform a POST request against the following endpoint: https://api.mediavalet.com/assetCheckIn/:id/validate
      :id is the assetId that was checked out.
      In the JSON Body, ensure to encase the name of the updated filename of the asset to be checked in as the new version as shown below:

634883d4-0456-46af-960d-3621f68eed63.png

  • Part B: Get an Upload Url for the Asset being checked-in
    • Perform a GET request against the following endpoint: https://api.mediavalet.com/assetCheckIn/:assetId

2040d62b-3753-44d2-b88b-69c14732c029.png

    • Copy the value found in the uploadUrl parameter as this will be needed for the next step. In our example above this was:

"uploadUrl": "https://mvsfservicefabriccato.blob.core.windows.net/medialibrary-6689ba35b0a04ba6b9f76e0da614d19e/3b9d4cc3b5be481e8ce1d5ba00a1245b/d51520cabc4e4cf4a1f2d39072fc1617/Original/moeder_en_zoon_low_res_0.jpg?sv=2017-04-17&sr=b&sig=48gi5ViQ1mrneddPr3bGmZ7HEQw67eZ5b2uMkGqWTHs%3D&st=2024-03-18T20%3A05%3A03Z&se=2024-03-20T20%3A20%3A03Z&sp=rw",

  • Part C: Upload File using Azure blob Storage
    • The upload is accomplished by issuing a PUT or a number of PUT requests against the SAS URL with the binary segments of the file as the body.
      Note: This SAS URL generated from Step 3 will expire after 24 hours and a new one will need to be generated at that point.

    • Maximum file size Azure supports is 200GB. If the file being uloaded is greater than 64MB, it needs to be broken up into segmented uploads. The maximum segment size is 64MB but we recommend using smaller segments for successful uploads.
      • This requirement would need to be fulfilled on the client’s end either via a C# code that would meet the segment limitation of 64MB imposed by Azure. MediaValet recommends using Azure SDK for this requirement. Alternatively, Azure does have a REST API available as shown here: Put Blob (REST API) - Azure Storage
      • If smaller than 64MB, please proceed with the following steps:
        • Perform a PUT request against the uploadUrl received in Part B’s response:
          ec842a1b-5284-4a86-802c-1659b3c94e0a.png
        • You will need to remove the Bearer Token authorization if performing the request from the same tab in Postman as the previous request.
        • Ensure to set the header value x-ms-blob-type with the value BlockBlob
        • d995e4a7-43d4-447b-970b-b222631a5a59.png
        • On the Body tab, select the option binary and then select the asset file from your local machine that should be used as the new version.
        • 3c44fef5-54d5-477b-ae4d-a31dd8cd1094.png
        • Click “Send” once complete. If successful, you will see a status of 201 Created.

 

Step 5: Finalize Upload/Set Asset Metadata
Once you have uploaded all segments in Part B to the SAS URL in Azure defined, you can finalize the check-in process by following the steps below:

  • Perform a PUT request agains the following endpoint: https://api.mediavalet.com/assetCheckIn/:assetId?priority=high
    • Please re-add the Bearer Token that was used initially to the Authorization section if using the same tab as the one Step 4, Part C (Upload to Azure) was performed in
    • In the Body tab, use the following JSON payload:
      {
      "id": "{assetId}",
      "uploadUrl": "{uploadUrl provided in Step 4B",
      "uploadFileName": "{uploadFileName provided in Step 4B}",
      "mediaFileId": "{mediaFileId provided in Step 4B}",
      "_links": {
      "self": "assetCheckIn",
      "functions": [
      "assetCheckIn"
      ]
      },
      "status": 0,
      "comment": "{Insert comments for the check-in if any}",
      "fileSizeInBytes": XXXXXX,
      "fileName": "{value of the filename used in Step 3}",
      "whenCancelled": {}
      }


Note: The fileSizeInBytes can be confirmed by accessing the properties for the new asset version uploaded on your local machine as shown below:

49139a50-c7c1-4986-a83a-13bf0a16ae34.png

An example of the request would look as follows:

6d181c6b-f0ec-4957-9842-f66cebc2652b.png

If successful, you should see a 202 Accepted response with the updated asset details. Navigate back to the library to confirm the check-in was successful (open the detailed info page and check Versions to make sure that a new version was uploaded).

Was this article helpful?
0 out of 0 found this helpful